Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<main class="login-page">
|
||||
<form class="login-form" aria-label="Вход" @submit.prevent="userLogin">
|
||||
<img class="login-logo" src="/logo2026.png" alt="CyberGarden" width="180" height="170" />
|
||||
<h1 class="login-title">Система оценки команд</h1>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
<input
|
||||
id="login"
|
||||
v-model.trim="login.login"
|
||||
class="text-input"
|
||||
name="username"
|
||||
autocomplete="username"
|
||||
aria-label="Логин"
|
||||
placeholder="Логин"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
id="password"
|
||||
v-model="login.password"
|
||||
class="text-input"
|
||||
name="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
aria-label="Пароль"
|
||||
placeholder="Пароль"
|
||||
required
|
||||
/>
|
||||
<button class="button button-primary" type="submit" :disabled="loading">
|
||||
{{ loading ? 'Входим…' : 'Войти' }}
|
||||
</button>
|
||||
</form>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Login',
|
||||
layout: 'empty',
|
||||
data() {
|
||||
return { login: { login: '', password: '' }, loading: false, error: '' }
|
||||
},
|
||||
mounted() {
|
||||
this.login.login = this.$route.query.l ?? ''
|
||||
this.login.password = this.$route.query.p ?? ''
|
||||
},
|
||||
methods: {
|
||||
async userLogin() {
|
||||
if (this.loading) return
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
try {
|
||||
const { data } = await this.$auth.loginWith('local', { data: this.login })
|
||||
this.$auth.setUser(data.user)
|
||||
localStorage.setItem('user.firstName', data.user.firstName || '')
|
||||
localStorage.setItem('user.lastName', data.user.lastName || '')
|
||||
await this.$router.push(data.user.login === 'admin' ? '/admin' : '/')
|
||||
} catch (e) {
|
||||
this.error =
|
||||
e.response?.status === 403
|
||||
? 'Проверьте логин и пароль и попробуйте ещё раз.'
|
||||
: 'Не удалось войти. Проверьте соединение и попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user