-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 0x73746F66 <[email protected]>
- Loading branch information
0x73746F66
committed
Jun 11, 2024
1 parent
ca4ceec
commit 9937250
Showing
3 changed files
with
19 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,14 @@ | |
import IconTrivialSecurity from '@images/IconTrivialSecurity.vue' | ||
import { useVuelidate } from '@vuelidate/core' | ||
import { email, required } from '@vuelidate/validators' | ||
import { PBKDF2 } from 'crypto-es/lib/pbkdf2' | ||
import axios from 'axios' | ||
import { SHA1 } from 'crypto-es/lib/sha1' | ||
import { reactive } from 'vue' | ||
import router from "../router" | ||
const initialState = { | ||
email: localStorage.getItem('/member/email') || '', | ||
password: '', | ||
rememberMe: false, | ||
} | ||
const state = reactive({ | ||
|
@@ -19,29 +19,18 @@ const state = reactive({ | |
const rules = { | ||
email: { required, email }, | ||
password: { required }, | ||
rememberMe: { required }, | ||
} | ||
const v$ = useVuelidate(rules, state) | ||
const isPasswordVisible = ref(false) | ||
const login = () => { | ||
const storedPassword = localStorage.getItem('/member/password') | ||
const storedSalt = localStorage.getItem('/member/password/salt') | ||
if (storedSalt && storedPassword && state.email && state.password) { | ||
// Do login | ||
// axios.get("http://local.getusers.com) | ||
// .then(response => { | ||
// this.users = response.data; | ||
// }) | ||
// .catch(error => { | ||
// console.log(error) | ||
// }) | ||
const passwordHash = PBKDF2(state.password, storedSalt, { keySize: 512/32, iterations: 1000 }).toString() | ||
if (storedPassword !== passwordHash) { | ||
console.log(403, 'Forbidden') | ||
return | ||
} | ||
if (state.email && state.password) { | ||
axios.get(`/login/${state.email}/${SHA1(state.password)}`) | ||
.then(console.log) | ||
.catch(console.log) | ||
localStorage.setItem('/member/email', state.email) | ||
localStorage.setItem('/session/token', "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0cmlhZ2UiLCJuYmYiOjE3MTgwMjQzNTgsImlhdCI6MTcxODAyNDM1OCwiZXhwIjoxNzE4MTEwNzU4LCJhdWQiOiJ1cm46dXVpZDowMGQwYzI3ZC1lNjA5LTRiMWMtYjIxMS02NzFjOGFjZDVhYWEiLCJpc3MiOiJ1cm46dXVpZDowMGQwYzI3ZC1lNjA5LTRiMWMtYjIxMS02NzFjOGFjZDVhYWEiLCJraWQiOiJ1cm46dXVpZDo0MjUwNWE1My05YzRiLTQ1OTgtYTcxYy03ZmQzMzI0ZGZhYTIiLCJuYW1lIjoiRGVtbyBVc2VyIiwicm9sZSI6InVybjp1dWlkOjdhZGE1YWNkLWQxOGYtNGZmNC04NDA5LTEzMjk3MmJhYmEyOCJ9.2bLuGpY9APA8qbPp73tk-7sDWO4IoLpC3ifRLWzs_O5jZG9b0kFtQhAo2DiBr_CRBsBYuMMb0zsxaW8Maa2uXQ") | ||
router.push('/dashboard') | ||
} | ||
|
@@ -50,20 +39,17 @@ const login = () => { | |
|
||
<template> | ||
<div class="auth-wrapper d-flex align-center justify-center pa-4"> | ||
<VCard | ||
class="auth-card pa-4 pt-7" | ||
max-width="448" | ||
> | ||
<VCard class="auth-card pa-4 pt-7" max-width="448"> | ||
<VCardItem class="justify-center"> | ||
<template #prepend> | ||
<div class="d-flex"> | ||
<IconTrivialSecurity class="d-flex text-primary" width="150"/> | ||
<IconTrivialSecurity class="d-flex text-primary" width="150" /> | ||
</div> | ||
</template> | ||
</VCardItem> | ||
|
||
<VCardText class="pt-2"> | ||
<h5 class="text-h5 mb-1 text-center"> | ||
<h5 class="text-h5 mb-1 text-center"> | ||
Trivial Triage | ||
</h5> | ||
<p class="mb-0"> | ||
|
@@ -76,61 +62,24 @@ const login = () => { | |
<VRow> | ||
<!-- email --> | ||
<VCol cols="12"> | ||
<VTextField | ||
v-model="state.email" | ||
autofocus | ||
placeholder="[email protected]" | ||
label="Email" | ||
type="email" | ||
/> | ||
<VTextField v-model="state.email" autofocus placeholder="[email protected]" label="Email" type="email" /> | ||
</VCol> | ||
|
||
<!-- password --> | ||
<VCol cols="12"> | ||
<VTextField | ||
required | ||
v-model="state.password" | ||
label="Password" | ||
placeholder="············" | ||
<VTextField required v-model="state.password" label="Password" placeholder="············" | ||
:type="isPasswordVisible ? 'text' : 'password'" | ||
:append-inner-icon="isPasswordVisible ? 'bx-hide' : 'bx-show'" | ||
@click:append-inner="isPasswordVisible = !isPasswordVisible" | ||
/> | ||
|
||
<!-- remember me checkbox --> | ||
<div class="d-flex align-center justify-space-between flex-wrap mt-1 mb-4"> | ||
<VCheckbox | ||
v-model="state.rememberMe" | ||
label="Remember me" | ||
/> | ||
|
||
<RouterLink | ||
class="text-primary ms-2 mb-1" | ||
to="javascript:void(0)" | ||
> | ||
Forgot Password? | ||
</RouterLink> | ||
</div> | ||
@click:append-inner="isPasswordVisible = !isPasswordVisible" /> | ||
|
||
<!-- login button --> | ||
<VBtn | ||
@click="v$.$validate" | ||
block | ||
text="Login" | ||
type="submit" | ||
/> | ||
<VBtn @click="v$.$validate" block text="Login" type="submit" /> | ||
</VCol> | ||
|
||
<!-- create account --> | ||
<VCol | ||
cols="12" | ||
class="text-center text-base" | ||
> | ||
<VCol cols="12" class="text-center text-base"> | ||
<span>New on our platform?</span> | ||
<RouterLink | ||
class="text-primary ms-2" | ||
to="/register" | ||
> | ||
<RouterLink class="text-primary ms-2" to="/register"> | ||
Create an account | ||
</RouterLink> | ||
</VCol> | ||
|
@@ -143,6 +92,7 @@ const login = () => { | |
|
||
<style lang="scss" scoped> | ||
@use "@core/scss/template/pages/page-auth.scss"; | ||
.v-btn { | ||
text-transform: none; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters