Compare commits
1 Commits
main
...
sifremi-si
| Author | SHA1 | Date | |
|---|---|---|---|
| b5a297e10c |
@ -48,7 +48,7 @@ axios.interceptors.response.use(
|
||||
const token = sessionStorage.getItem(usersStore.userStorageKeys.TOKEN)
|
||||
if (token !== undefined) {
|
||||
usersStore.ResetUserData()
|
||||
router.push('/login')
|
||||
router.push('/giris')
|
||||
}
|
||||
}
|
||||
return Promise.reject(error)
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
let dt = await dataStore.dataPost('Auth/logout')
|
||||
}
|
||||
usersStore.ResetUserData()
|
||||
router.push('/login')
|
||||
router.push('/giris')
|
||||
}
|
||||
|
||||
const closeProfileMenu = (e: Event) => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import ForgotPassword from '@/module/auth/views/ForgotPassword.vue'
|
||||
|
||||
export default {
|
||||
path: '/forgot-password',
|
||||
path: '/sifremi-unuttum',
|
||||
name: 'ForgotPassword',
|
||||
component: ForgotPassword,
|
||||
meta: {
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import Login from "@/module/auth/routes/login";
|
||||
import Register from "@/module/auth/routes/register";
|
||||
import ForgotPassword from "@/module/auth/routes/forgot-password";
|
||||
|
||||
export default [
|
||||
Login,
|
||||
Register,
|
||||
ForgotPassword
|
||||
]
|
||||
|
||||
import Login from '@/module/auth/routes/login'
|
||||
import Register from '@/module/auth/routes/register'
|
||||
import ForgotPassword from '@/module/auth/routes/forgot-password'
|
||||
import ResetPassword from '@/module/auth/routes/reset-password'
|
||||
|
||||
export default [Login, Register, ForgotPassword, ResetPassword]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import Login from '@/module/auth/views/Login.vue'
|
||||
|
||||
export default {
|
||||
path: '/login',
|
||||
path: '/giris',
|
||||
name: 'Login',
|
||||
component: Login,
|
||||
meta: {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import Register from '@/module/auth/views/Register.vue'
|
||||
|
||||
export default {
|
||||
path: '/register',
|
||||
path: '/kayit-ol',
|
||||
name: 'Register',
|
||||
component: Register,
|
||||
meta: {
|
||||
|
||||
10
src/module/auth/routes/reset-password.ts
Normal file
10
src/module/auth/routes/reset-password.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import ResetPassword from '@/module/auth/views/ResetPassword.vue'
|
||||
|
||||
export default {
|
||||
path: '/sifreyi-sifirla',
|
||||
name: 'ResetPassword',
|
||||
component: ResetPassword,
|
||||
meta: {
|
||||
authpage: true
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,59 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useDataStore } from '@/stores/dataStore'
|
||||
import { useAuthStore } from '../stores/authStore'
|
||||
import { useAuthValidationStore } from '../validation/authValidationStore'
|
||||
import { useUsersStore } from '@/stores/usersStore'
|
||||
import router from '@/router'
|
||||
|
||||
export const useAppService = defineStore('appService', () => {
|
||||
export const useAuthService = defineStore('authService', () => {
|
||||
const dataStore = useDataStore()
|
||||
const authStore = useAuthStore()
|
||||
const authValidationStore = useAuthValidationStore()
|
||||
const usersStore = useUsersStore()
|
||||
|
||||
const GetAAuthRoleList = async () => {
|
||||
if (authStore.rolesList.length === 0) {
|
||||
let data = await dataStore.dataGet('Auth/rolelistesi')
|
||||
authStore.rolesList = data
|
||||
const Login = async () => {
|
||||
if (authValidationStore.LoginFormCheck()) {
|
||||
let login = await dataStore.dataPost('Auth/login', {
|
||||
data: authStore.loginData
|
||||
})
|
||||
Object.assign(authStore.loginData, authStore.safeLoginData)
|
||||
if (login !== 'errorfalse') {
|
||||
await usersStore.SetUserSessionData(login)
|
||||
await usersStore.SetUserData()
|
||||
|
||||
if (usersStore.isPanelUser) {
|
||||
router.push('/')
|
||||
} else {
|
||||
if (usersStore.userStatus === 0 || usersStore.userStatus === null) {
|
||||
router.push('/profil')
|
||||
} else {
|
||||
router.push('/')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
authValidationStore.loginMessageType = 'alert'
|
||||
authValidationStore.loginMessage =
|
||||
'Kullanıcı adı veya şifrenizi yanlış girdiniz. Lütfen kontrol edip tekrar deneyiniz.'
|
||||
authValidationStore.isLoginMessage = true
|
||||
}
|
||||
} else {
|
||||
authValidationStore.isLoginFormValid = true
|
||||
}
|
||||
}
|
||||
|
||||
return {GetAAuthRoleList}
|
||||
const ResetPassword = async () => {
|
||||
if (authValidationStore.ResetPasswordFormCheck()) {
|
||||
let dt: any
|
||||
|
||||
dt = await dataStore.dataPost('ResetPassword', {
|
||||
data: authStore.resetPasswordForm
|
||||
})
|
||||
if (dt !== 'errorfalse') {
|
||||
}
|
||||
} else {
|
||||
authValidationStore.isResetPasswordFormValid = true
|
||||
}
|
||||
}
|
||||
|
||||
return { Login, ResetPassword }
|
||||
})
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref,reactive } from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
export const useAuthStore = defineStore('authStore', () => {
|
||||
const loginData = reactive<Record<string, any>>({ username: '', password: '' })
|
||||
const safeLoginData = reactive<Record<string, any>>({})
|
||||
const rolesList = ref<Record<string, any>[]>([])
|
||||
const resetCheckData = ref<string>('')
|
||||
|
||||
const resetPasswordForm = reactive<Record<string, any>>({
|
||||
newPassword: '',
|
||||
newPasswordRepeat: '',
|
||||
check: ''
|
||||
})
|
||||
|
||||
Object.assign(safeLoginData, loginData)
|
||||
|
||||
return { loginData, safeLoginData, rolesList }
|
||||
return { loginData, safeLoginData, rolesList, resetPasswordForm, resetCheckData }
|
||||
})
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useAuthStore } from './authStore'
|
||||
import { useValidationStore } from '@/stores/validationStore'
|
||||
|
||||
export const useAuthValidationStore = defineStore('authValidationStore', () => {
|
||||
const authStore = useAuthStore()
|
||||
const validationStore = useValidationStore()
|
||||
|
||||
const isFormValid = ref<boolean>(true)
|
||||
const isLoginMessage = ref<boolean>(false)
|
||||
const loginMessageType = ref<string>('success')
|
||||
const loginMessage = ref<string>('')
|
||||
const registerMessage = ref<string>('')
|
||||
const invalidTexts = reactive<Record<string, any>>({})
|
||||
|
||||
const FormCheck = (): boolean => {
|
||||
Object.assign(invalidTexts, {})
|
||||
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.loginData,
|
||||
invalidTexts,
|
||||
'username',
|
||||
'Kullanıcı adı alanını doldurmalısınız. Örn: isim@alanadi.td'
|
||||
)
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.loginData,
|
||||
invalidTexts,
|
||||
'password',
|
||||
'Lütfen şifrenizi giriniz.'
|
||||
)
|
||||
|
||||
isFormValid.value = Object.keys(invalidTexts).length === 0
|
||||
return isFormValid.value
|
||||
}
|
||||
|
||||
return {
|
||||
isFormValid,
|
||||
invalidTexts,
|
||||
isLoginMessage,
|
||||
loginMessageType,
|
||||
loginMessage,
|
||||
registerMessage,
|
||||
FormCheck
|
||||
}
|
||||
})
|
||||
89
src/module/auth/validation/authValidationStore.ts
Normal file
89
src/module/auth/validation/authValidationStore.ts
Normal file
@ -0,0 +1,89 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useValidationStore } from '@/stores/validationStore'
|
||||
import { useAuthStore } from '../stores/authStore'
|
||||
|
||||
export const useAuthValidationStore = defineStore('authValidationStore', () => {
|
||||
const validationStore = useValidationStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const isLoginMessage = ref<boolean>(false)
|
||||
const loginMessageType = ref<string>('success')
|
||||
const loginMessage = ref<string>('')
|
||||
const registerMessage = ref<string>('')
|
||||
|
||||
const loginInvalidTexts = reactive<Record<string, any>>({})
|
||||
const isLoginFormValid = ref<boolean>(true)
|
||||
const resetPasswordFormChanged = ref<boolean>(false)
|
||||
const isResetPasswordFormValid = ref<boolean>(true)
|
||||
const resetPasswordInvalidTexts = reactive<Record<string, any>>({})
|
||||
|
||||
const LoginFormCheck = (): boolean => {
|
||||
Object.assign(loginInvalidTexts, {})
|
||||
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.loginData,
|
||||
loginInvalidTexts,
|
||||
'username',
|
||||
'Kullanıcı adı alanını doldurmalısınız. Örn: isim@alanadi.td'
|
||||
)
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.loginData,
|
||||
loginInvalidTexts,
|
||||
'password',
|
||||
'Lütfen şifrenizi giriniz.'
|
||||
)
|
||||
|
||||
isLoginFormValid.value = Object.keys(loginInvalidTexts).length === 0
|
||||
return isLoginFormValid.value
|
||||
}
|
||||
|
||||
const ResetPasswordFormCheck = (): boolean => {
|
||||
Object.assign(resetPasswordInvalidTexts, {})
|
||||
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.resetPasswordForm,
|
||||
resetPasswordInvalidTexts,
|
||||
'newPassword',
|
||||
'Lütfen yeni şifrenizi giriniz.'
|
||||
)
|
||||
|
||||
validationStore.IsFieldEmpty(
|
||||
authStore.resetPasswordForm,
|
||||
resetPasswordInvalidTexts,
|
||||
'newPasswordRepeat',
|
||||
'Lütfen yeni şifrenizi tekrar giriniz.'
|
||||
)
|
||||
|
||||
if (
|
||||
!validationStore.checkEmpty(authStore.resetPasswordForm.newPassword) &&
|
||||
!validationStore.checkEmpty(authStore.resetPasswordForm.newPasswordRepeat)
|
||||
) {
|
||||
if (
|
||||
authStore.resetPasswordForm.newPassword !==
|
||||
authStore.resetPasswordForm.newPasswordRepeat
|
||||
) {
|
||||
isResetPasswordFormValid.value = false
|
||||
resetPasswordInvalidTexts.newPasswordRepeat =
|
||||
'Şifrenizi tekrar doğru girdiğinizden emin olunuz.'
|
||||
}
|
||||
}
|
||||
|
||||
isResetPasswordFormValid.value = Object.keys(resetPasswordInvalidTexts).length === 0
|
||||
return isResetPasswordFormValid.value
|
||||
}
|
||||
|
||||
return {
|
||||
isLoginMessage,
|
||||
loginMessageType,
|
||||
loginMessage,
|
||||
loginInvalidTexts,
|
||||
registerMessage,
|
||||
isLoginFormValid,
|
||||
resetPasswordFormChanged,
|
||||
isResetPasswordFormValid,
|
||||
resetPasswordInvalidTexts,
|
||||
LoginFormCheck,
|
||||
ResetPasswordFormCheck
|
||||
}
|
||||
})
|
||||
@ -24,7 +24,7 @@
|
||||
</button>
|
||||
</form>
|
||||
<div class="login-nav login-nav-back">
|
||||
<RouterLink to="/login">< Geri</RouterLink>
|
||||
<RouterLink to="/giris">< Geri</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -3,14 +3,12 @@
|
||||
<section class="section-login">
|
||||
<div class="login-header">
|
||||
<div class="logo-header">
|
||||
<img
|
||||
src="@/assets/images/cekilisevi-logo-n.png"
|
||||
alt="MPI Çekiliş Evi"/>
|
||||
<img src="@/assets/images/cekilisevi-logo-n.png" alt="MPI Çekiliş Evi" />
|
||||
</div>
|
||||
<h1>Giriş Yap</h1>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<form action="#" id="login-form" @submit.prevent="Login">
|
||||
<form action="#" id="login-form" @submit.prevent="authService.Login">
|
||||
<form-input
|
||||
type="email"
|
||||
modelKey="username"
|
||||
@ -18,12 +16,11 @@
|
||||
required
|
||||
label="Kullanıcı Adı (e-posta adresi)"
|
||||
placeholder="eposta@alanadi.com"
|
||||
:invalidText="authValidationStore.invalidTexts.username" />
|
||||
:invalidText="authValidationStore.loginInvalidTexts.username" />
|
||||
|
||||
<form-input
|
||||
type="password"
|
||||
label="Şifre"
|
||||
|
||||
v-model="authStore.loginData.password"
|
||||
required />
|
||||
|
||||
@ -32,64 +29,38 @@
|
||||
v-if="authValidationStore.isLoginMessage">
|
||||
<span>{{ authValidationStore.loginMessage }}</span>
|
||||
</div>
|
||||
<button class="button-c button-second button-login" type="submit">
|
||||
<button
|
||||
class="button-c button-second button-login"
|
||||
type="submit"
|
||||
@submit="authService.Login"
|
||||
@click="authService.Login">
|
||||
Giriş Yap
|
||||
</button>
|
||||
</form>
|
||||
<div class="login-nav">
|
||||
<RouterLink to="/forgot-password">Şifremi Unuttum</RouterLink>
|
||||
<RouterLink to="/register">Kaydol</RouterLink>
|
||||
<RouterLink to="/sifremi-unuttum">Şifremi Unuttum</RouterLink>
|
||||
<RouterLink to="/kayit-ol">Kayıt Ol</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</GuestLayout>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onBeforeMount, reactive, ref } from 'vue'
|
||||
import { onBeforeMount } from 'vue'
|
||||
|
||||
import { useUsersStore } from '@/stores/usersStore'
|
||||
const usersStore = useUsersStore()
|
||||
import { useDataStore } from '@/stores/dataStore'
|
||||
const dataStore = useDataStore()
|
||||
import { useAuthStore } from '../stores/authStore'
|
||||
const authStore = useAuthStore()
|
||||
import { useAuthValidationStore } from '../stores/authValidationStore'
|
||||
import { useAuthValidationStore } from '../validation/authValidationStore'
|
||||
const authValidationStore = useAuthValidationStore()
|
||||
import { useAuthService } from '../services/authService'
|
||||
const authService = useAuthService()
|
||||
import router from '@/router'
|
||||
|
||||
import GuestLayout from '@/layouts/GuestLayout.vue'
|
||||
|
||||
const Login = async () => {
|
||||
if (authValidationStore.FormCheck()) {
|
||||
let login = await dataStore.dataPost('Auth/login', {
|
||||
data: authStore.loginData
|
||||
})
|
||||
Object.assign(authStore.loginData, authStore.safeLoginData)
|
||||
if (login !== 'errorfalse') {
|
||||
await usersStore.SetUserSessionData(login)
|
||||
await usersStore.SetUserData()
|
||||
|
||||
if (usersStore.isPanelUser) {
|
||||
router.push('/')
|
||||
} else {
|
||||
if (usersStore.userStatus === 0 || usersStore.userStatus === null) {
|
||||
router.push('/profil')
|
||||
} else {
|
||||
router.push('/')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
authValidationStore.loginMessageType = 'alert'
|
||||
authValidationStore.loginMessage =
|
||||
'Kullanıcı adı veya şifrenizi yanlış girdiniz. Lütfen kontrol edip tekrar deneyiniz.'
|
||||
authValidationStore.isLoginMessage = true
|
||||
}
|
||||
} else {
|
||||
authValidationStore.isFormValid = true
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
if(usersStore.userIsAuth) router.push('/')
|
||||
onBeforeMount(() => {
|
||||
if (usersStore.userIsAuth) router.push('/')
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -339,7 +339,7 @@
|
||||
</button>
|
||||
</form>
|
||||
<div class="login-nav login-nav-back">
|
||||
<RouterLink to="/login">< Geri</RouterLink>
|
||||
<RouterLink to="/giris">< Geri</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@ -355,7 +355,7 @@
|
||||
const globalDataStore = useGlobalDataStore()
|
||||
import { useValidationStore } from '@/stores/validationStore'
|
||||
const validationStore = useValidationStore()
|
||||
import { useAuthValidationStore } from '../stores/authValidationStore'
|
||||
import { useAuthValidationStore } from '../validation/authValidationStore'
|
||||
const authValidationStore = useAuthValidationStore()
|
||||
import router from '@/router'
|
||||
|
||||
@ -413,7 +413,7 @@
|
||||
'Başarıyla kayıt oldunuz. Kullanıcı adı ve şifreniz ile giriş yapabilirsiniz.'
|
||||
authValidationStore.isLoginMessage = true
|
||||
|
||||
router.push('/login')
|
||||
router.push('/giris')
|
||||
}
|
||||
} else {
|
||||
uyeBilgileriStore.isFormValid = true
|
||||
|
||||
62
src/module/auth/views/ResetPassword.vue
Normal file
62
src/module/auth/views/ResetPassword.vue
Normal file
@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<GuestLayout>
|
||||
<section class="section-login">
|
||||
<div class="login-header">
|
||||
<div class="logo-header">
|
||||
<img src="@/assets/images/cekilisevi-logo-n.png" alt="MPI Çekiliş Evi" />
|
||||
</div>
|
||||
<h1>Şifremi Sıfırla</h1>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<form id="sifremi-unuttum" @submit.prevent="authService.ResetPassword">
|
||||
<form-input
|
||||
type="password"
|
||||
modelKey="newPassword"
|
||||
v-model="authStore.resetPasswordForm.newPassword"
|
||||
required
|
||||
label="Yeni Şifre"
|
||||
placeholder="Yeni Şifre"
|
||||
:invalidText="authValidationStore.resetPasswordInvalidTexts.newPassword" />
|
||||
<form-input
|
||||
type="password"
|
||||
modelKey="newPasswordRepeat"
|
||||
v-model="authStore.resetPasswordForm.newPasswordRepeat"
|
||||
required
|
||||
label="Yeni Şifre Tekrar"
|
||||
placeholder="Yeni Şifre Tekrar"
|
||||
:invalidText="
|
||||
authValidationStore.resetPasswordInvalidTexts.newPasswordRepeat
|
||||
" />
|
||||
<button
|
||||
class="button-c button-second button-login"
|
||||
type="submit"
|
||||
@submit="authService.ResetPassword"
|
||||
@click="authService.ResetPassword">
|
||||
Şifremi Sıfırla
|
||||
</button>
|
||||
</form>
|
||||
<div class="login-nav login-nav-back">
|
||||
<RouterLink to="/giris">< Geri</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</GuestLayout>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import GuestLayout from '@/layouts/GuestLayout.vue'
|
||||
import { useAuthStore } from '../stores/authStore'
|
||||
const authStore = useAuthStore()
|
||||
import { useAuthService } from '../services/authService'
|
||||
const authService = useAuthService()
|
||||
import { useAuthValidationStore } from '../validation/authValidationStore'
|
||||
const authValidationStore = useAuthValidationStore()
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
onMounted(() => {
|
||||
if (route.query && route.query.check !== undefined)
|
||||
authStore.resetCheckData = route.query.check as string
|
||||
else router.push('/giris')
|
||||
})
|
||||
</script>
|
||||
@ -39,7 +39,7 @@ router.beforeEach((to, from) => {
|
||||
const usersStore = useUsersStore()
|
||||
|
||||
if (to.meta.authRequired && !usersStore.userIsAuth && from.name !== 'Login') {
|
||||
router.push('/login')
|
||||
router.push('/giris')
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user