Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend_idatt2105
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Oskar Langås Eidem
frontend_idatt2105
Commits
3aedc6e3
Commit
3aedc6e3
authored
Apr 1, 2022
by
Oskar Langås Eidem
Browse files
Options
Downloads
Patches
Plain Diff
lololo
parent
8eae7d8b
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#171103
failed
Apr 1, 2022
Stage: build
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/LoginForm.vue
+27
-23
27 additions, 23 deletions
src/components/LoginForm.vue
src/store/index.js
+12
-78
12 additions, 78 deletions
src/store/index.js
src/views/Login.vue
+5
-1
5 additions, 1 deletion
src/views/Login.vue
with
44 additions
and
102 deletions
src/components/LoginForm.vue
+
27
−
23
View file @
3aedc6e3
...
@@ -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('validat
eLogin
')
"
>
Login
</button>
<button
type=
"button"
@
click=
"handl
eLogin"
>
Login
</button>
<p
@
click=
"
$store.commit('setF
orgotPassword
')
"
class=
"forgot"
>
Forgot password?
</p>
<p
@
click=
"
f
orgotPassword"
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
(
new
Password
)
{
forgot
Password
(
)
{
this
.
$store
.
commit
(
'
setCurren
tPassword
'
,
newPassword
)
this
.
$store
.
commit
(
'
forgo
tPassword
'
)
}
}
},
},
}
}
}
</
script
>
</
script
>
...
...
This diff is collapsed.
Click to expand it.
src/store/index.js
+
12
−
78
View file @
3aedc6e3
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
:
tru
e
,
// den her
loggedIn
:
fals
e
,
// 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
set
Current
Email
(
state
,
newEmail
)
{
setEmail
(
state
,
newEmail
)
{
state
.
currentEmail
=
newEmail
state
.
currentEmail
=
newEmail
},
},
set
Current
Password
(
state
,
newPassword
)
{
setPassword
(
state
,
newPassword
)
{
state
.
currentPassword
=
newPassword
state
.
currentPassword
=
newPassword
},
},
set
Forgot
Password
(
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
}
}
...
...
This diff is collapsed.
Click to expand it.
src/views/Login.vue
+
5
−
1
View file @
3aedc6e3
...
@@ -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
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment