Skip to content

Commit

Permalink
remove unused code from Login.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
wen-templari committed Nov 29, 2023
1 parent 957f786 commit c74c4a4
Showing 1 changed file with 1 addition and 83 deletions.
84 changes: 1 addition & 83 deletions src/views/Login/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,6 @@
<div class="w-[18vw] sm:h-auto" style="min-width: 250px">
<img src="../../assets/images/logo.png" alt="" class="filter drop-shadow" />
</div>
<!-- <form @submit.prevent="login" class="grid gap-4 place-items-center" style="width: 20vw; min-width: 300px">
<InputBase
placeholder="ID"
hint="学号"
maxLength="10"
required
:passWarning="isIDValid"
class="w-full"
v-model:content="accountInput.id"
:rules="[{ rule: /^\d{10}$/, warning: '格式错误' }]"
/>
<InputBase
placeholder="密码"
:passWarning="isPasswordValid"
type="password"
class="w-full"
v-model:content="accountInput.password"
/>
<button class="w-full btn bg-gradient-to-b from-primary/80 to-primary text-primaryContent shadow-md" type="submit">登入</button>
</form> -->
<button
class="w-full btn bg-gradient-to-b from-primary/80 to-primary text-primaryContent shadow-md mt-10 w-84"
type="submit"
Expand All @@ -38,72 +18,10 @@
</div>
</template>
<script setup lang="ts">
import { isFormValid } from "@/utils/isFormValid"
import InputBase from "@/components/Input/InputBase.vue"
import { onMounted, ref } from "vue"
import router from "@/router"
import md5 from "blueimp-md5"
import MemberService from "@/services/member"
import { useAccountStore } from "@/stores/account"
import { useLogto } from "@logto/vue"
import { convertToObject } from "typescript"
const store = useAccountStore()
const accountInput = ref({
id: "",
password: "",
})
const isIDValid = ref("")
const isPasswordValid = ref("")
const { signIn, isAuthenticated } = useLogto()
const { signIn } = useLogto()
const onSighInWithLogto = () => {
return signIn(import.meta.env.VITE_LOGTO_CALLBACK_URL)
}
const login = async () => {
isPasswordValid.value = ""
const account = isFormValid(accountInput.value)
if (!account) return
let hashedPassword = ""
if (account.password != undefined && account.password != "") {
hashedPassword = md5(account.password)
}
try {
const res = await MemberService.createToken({
id: account.id,
password: hashedPassword,
})
store.account = res
store.token = res.token
if (res.role.includes("inactive")) {
router.push("/activate")
router.push("/activate")
} else {
router.push("/Events")
}
} catch (error) {
const errorData = error.response.data as any
console.log(error)
if (!errorData.errors || errorData.errors.length == 0) {
return
}
if (errorData.errors[0].field == "password") {
isPasswordValid.value = "密码错误"
}
if (errorData.errors[0].field == "memberId") {
isIDValid.value = "ID不存在"
}
// if(!error.response.data || !error.response.data.errors ||)
// console.log(error.response.data)
}
}
// onMounted(() => {
// try {
// onSighInWithLogto()
// } catch (error) {
// console.log(error)
// }
// })
</script>

0 comments on commit c74c4a4

Please sign in to comment.