Skip to content
Snippets Groups Projects
Commit 3aedc6e3 authored by Oskar Langås Eidem's avatar Oskar Langås Eidem
Browse files

lololo

parent 8eae7d8b
Branches
No related tags found
No related merge requests found
Pipeline #171103 failed
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
<div v-if="$store.state.message != ''"> <div v-if="$store.state.message != ''">
<ErrorBox /> <ErrorBox />
</div> </div>
<form data-test="form"> <form @submit.prevent="handleLogin" >
<label>Email:</label> <label>Email:</label>
<input data-test="notStoredUser" type="email" required v-model="email"> <input data-test="notStoredUser" type="email" required v-model="email">
<label>Password:</label> <label>Password:</label>
<input data-test="notStoredPassword" type="password" required v-model="password"> <input type="password" required v-model="password">
<div class="loginDiv"> <div class="loginDiv">
<button type="button" data-test="loginButton" @click="$store.commit('validateLogin')">Login</button> <button type="button" @click="handleLogin">Login</button>
<p @click="$store.commit('setForgotPassword')" class="forgot">Forgot password?</p> <p @click="forgotPassword" class="forgot">Forgot password?</p>
</div> </div>
</form> </form>
...@@ -28,27 +28,31 @@ export default { ...@@ -28,27 +28,31 @@ export default {
components: {ErrorBox}, components: {ErrorBox},
data() {
return {
computed: { email: '',
email: { password: ''
get() {
return this.$store.state.currentEmail;
},
set(newEmail) {
this.$store.commit('setCurrentEmail', newEmail)
} }
}, },
password: {
get() { methods: {
return this.$store.state.currentPassword; handleLogin() {
this.$router.push('/Subjects')
this.$store.dispatch('authenticate', this.email, this.password)
console.log('dude')
}, },
set(newPassword) { forgotPassword() {
this.$store.commit('setCurrentPassword', newPassword) this.$store.commit('forgotPassword')
} }
}, },
}
} }
</script> </script>
......
import axios from 'axios';
import { createStore } from 'vuex' import { createStore } from 'vuex'
export default createStore({ export default createStore({
state: { // variables accessable from anywhere within the app state: { // variables accessable from anywhere within the app
currentEmail: '',
currentPassword: '',
currentView:'', // den her currentView:'', // den her
Email: '', // den her Email: '', // den her
password: '', // den her password: '', // den her
message: '',
loggedIn: true, // den her loggedIn: false, // den her
forgotPassword: false, forgotPassword: false,
activeOption: '', // den her activeOption: '', // den her
subjects: [
{subject_id: 'IDATT2105_V2022', subjectName: 'Fullstack', subjectCode: 'IDATT2105', semester: 'V2022', online: true, archived: false, students_in_queue: 5},
{subject_id: 'IDATT2106_V2022', subjectName: 'Databaser', subjectCode: 'IDATT2106', semester: 'V2022', online: true, archived: false, students_in_queue: 5},
{subject_id: 'IDATT2107_V2022', subjectName: 'Algoritmer', subjectCode: 'IDATT2107', semester: 'V2022', online: true, archived: false, students_in_queue: 5},
{subject_id: 'IDATT2108_V2021', subjectName: 'Matematikk 1', subjectCode: 'IDATT2108', semester: 'V2021', online: true, archived: true, students_in_queue: 5},
{subject_id: 'IDATT2109_V2021', subjectName: 'Programmering 1', subjectCode: 'IDATT2109', semester: 'V2021', online: true, archived: true, students_in_queue: 5},
], // aktive emner currentOption: 'Student', // den her
// variable to change nav option --> student, studass, arkivert
currentOption: 'student',
currentSubject: '', currentSubject: '',
queue: [
{student_name: 'Oskar Eidem', type: 'godkjenning', position: '1', stud_ass: 'Lea Grønningen'},
{student_name: 'Kristian Aars', type: 'godkjenning', position: '2', stud_ass: 'Ole Brum'},
{student_name: 'Petter Dass', type: 'Hjelp', position: '3', stud_ass: ''},
{student_name: 'Kis Dude', type: 'godkjenning', position: '4', stud_ass: ''},
],
exercises: [{subject_id: 'IDATT2105_V2022', exercise_name: 'Øving1', exercise_info: 'Frist 15.04.2022', is_complete: true},
{subject_id: 'IDATT2105_V2022', exercise_name: 'Øving2', exercise_info: 'Frist 26.04.2022', is_complete: false},
{subject_id: 'IDATT2105_V2022', exercise_name: 'Øving3', exercise_info: 'Frist 05.05.2022', is_complete: false},
{subject_id: 'IDATT2105_V2022', exercise_name: 'Øving4', exercise_info: 'Frist 14.05.2022', is_complete: false},
],
// queueForm
location: '',
godkjenning: true,
table: '',
currentExercise: '',
}, },
getters: { // data from state can be accessed directly. But with getters we can do some filtering before getting the returned value(s). getters: { // data from state can be accessed directly. But with getters we can do some filtering before getting the returned value(s).
}, },
mutations: { // methods to change variables within the state mutations: { // methods to change variables within the state
setCurrentEmail(state, newEmail) { setEmail(state, newEmail) {
state.currentEmail = newEmail state.currentEmail = newEmail
}, },
setCurrentPassword(state, newPassword) { setPassword(state, newPassword) {
state.currentPassword = newPassword state.currentPassword = newPassword
}, },
setForgotPassword(state) { setPassword(state) {
state.forgotPassword = !state.forgotPassword state.forgotPassword = !state.forgotPassword
state.message = '' state.message = ''
}, },
...@@ -65,55 +38,16 @@ export default createStore({ ...@@ -65,55 +38,16 @@ export default createStore({
setActiveOption(state, option) { setActiveOption(state, option) {
state.activeOption = option state.activeOption = option
}, },
validateLogin(state) {
let format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
let valid = true
if(state.currentPassword.length < 8) { setLogin(state, newEmail, newPassword) {
state.message = 'Password length must be greater than 7' // bruk i authenticate metode
valid = false
}
else if(format.test(state.currentPassword)) {
state.message = "Password can't contain any special characters"
valid = false
}
else {
state.message = ''
}
return valid
// hvis api også returnerer noe --> setPassword --> setEmail --> loggedIn = true --> Subjects view
}, },
setMessage(state, newMessage) {
state.message = newMessage
},
//queueForm
setLocation(state, newLocation) {
state.location = newLocation
},
setTable(state, newTable) {
state.table = newTable
}, },
openQueueForm(state, newCurrentExercise) {
if(state.currentExercise !== '') {
state.currentExercise = ''
}
else {
state.currentExercise = newCurrentExercise
}
}
},
actions: { // asynchronous way to change variables within the state
getQueue(state) {
axios.get('https://jsonplaceholder.typicode.com/posts')
.then(res => console.log(res))
}
},
modules: { // to split the store into modules modules: { // to split the store into modules
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<ForgotPassword /> <ForgotPassword />
</div> </div>
<div v-else> <div v-else>
<LoginForm /> <LoginForm @transfer="transfer" />
</div> </div>
...@@ -21,6 +21,10 @@ export default { ...@@ -21,6 +21,10 @@ export default {
name: 'Login', name: 'Login',
components: {LoginForm, ForgotPassword}, components: {LoginForm, ForgotPassword},
methods: {
}
} }
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment