This commit is contained in:
j3d1 2023-12-11 22:18:33 +01:00
parent 6aaa522a6b
commit ba427c7a84
25 changed files with 274 additions and 236 deletions

View file

@ -138,17 +138,22 @@ const store = new Vuex.Store({
actions: {
async login({commit, dispatch, state}, {username, password, remember}) {
commit('setRemember', remember);
const data = await fetch('/api/2/auth/token/', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: username, password: password}),
credentials: 'omit'
}).then(r => r.json())
if (data.token && data.key) {
commit('setToken', data.token);
commit('setUser', username);
return true;
} else {
try{
const data = await fetch('/api/2/token/', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: username, password: password}),
credentials: 'omit'
}).then(r => r.json())
if (data.token && data.key) {
commit('setToken', data.token);
commit('setUser', username);
return true;
} else {
return false;
}
} catch (e) {
console.error(e);
return false;
}
},

View file

@ -31,6 +31,19 @@
</div>
</div>
<div :class="errors.email?['mb-3','is-invalid']:['mb-3']">
<label class="form-label">E-Mail</label>
<div class="input-group">
<input class="form-control"
type="email" v-model="form.email" id="validationCustomEmail"
placeholder="Enter your email" required/>
</div>
<div class="invalid-feedback">
{{ errors.email }}
</div>
</div>
<div :class="errors.password?['mb-3','is-invalid']:['mb-3']">
<label class="form-label">Password</label>
<input class="form-control" type="password"
@ -79,11 +92,13 @@ export default {
form: {
username: '',
password: '',
email: '',
},
errors: {
username: null,
password: null,
password2: null,
email: null,
}
}
},
@ -97,7 +112,7 @@ export default {
} else {
this.errors.password2 = null;
}
fetch('/api/2/auth/register/', {
fetch('/api/2/register/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -135,7 +150,7 @@ export default {
display: block;
}
input{
input {
background-color: var(--dark);
border: var(--gray) 1px solid;;