Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-frontend
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106_2022_02
boco-frontend
Commits
1a909050
Commit
1a909050
authored
2 years ago
by
Zara Mudassar
Browse files
Options
Downloads
Patches
Plain Diff
Token saving in store added
parent
690508a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/components/LoginForm.vue
+13
-24
13 additions, 24 deletions
src/components/LoginForm.vue
src/store/index.js
+6
-1
6 additions, 1 deletion
src/store/index.js
src/store/modules/user.js
+17
-0
17 additions, 0 deletions
src/store/modules/user.js
src/utils/apiutil.js
+0
-8
0 additions, 8 deletions
src/utils/apiutil.js
with
36 additions
and
33 deletions
src/components/LoginForm.vue
+
13
−
24
View file @
1a909050
...
@@ -2,24 +2,6 @@
...
@@ -2,24 +2,6 @@
<div
class=
"loginForm"
>
<div
class=
"loginForm"
>
<v-img
:src=
"require('../assets/logo3.svg')"
class=
"image"
contain
/>
<v-img
:src=
"require('../assets/logo3.svg')"
class=
"image"
contain
/>
<form
@
submit.prevent=
"onSubmit"
>
<form
@
submit.prevent=
"onSubmit"
>
<!--
<div
class=
"inputFields"
>
<br><label
class=
"label"
>
E-post
</label><br>
<input
class=
"loginInputs"
type=
"text"
v-model=
"v$.user.email.$model"
/>
<br><label
class=
"label"
><br>
Passord
</label><br>
<input
class=
"loginInputs"
type=
"password"
v-model=
"v$.user.password.$model"
/>
<br><a
href=
"url"
id=
"forgottenPasswordLink"
>
Glemt passord
</a>
</div>
<br><br>
<div
class=
"buttonLink"
>
<button
class=
"loginButton"
type=
"submit"
@
click=
"loginClicked"
>
LOGG INN
</button>
<br><a
id=
"newUserLink"
href=
"url"
>
Ny bruker
</a>
<p
id=
"messageUser"
>
{{
message
}}
</p>
</div>
-->
<div
class=
"inputFields"
>
<div
class=
"inputFields"
>
<div
:class=
"
{ error: v$.user.email.$errors.length }">
<div
:class=
"
{ error: v$.user.email.$errors.length }">
<br
/><label
class=
"label"
id=
"emailLabelId"
>
E-post
</label><br
/>
<br
/><label
class=
"label"
id=
"emailLabelId"
>
E-post
</label><br
/>
...
@@ -87,6 +69,7 @@
...
@@ -87,6 +69,7 @@
import
useVuelidate
from
"
@vuelidate/core
"
;
import
useVuelidate
from
"
@vuelidate/core
"
;
import
{
required
,
email
,
minLength
,
helpers
}
from
"
@vuelidate/validators
"
;
import
{
required
,
email
,
minLength
,
helpers
}
from
"
@vuelidate/validators
"
;
import
{
doLogin
}
from
"
@/utils/apiutil
"
;
import
{
doLogin
}
from
"
@/utils/apiutil
"
;
import
{
mapState
}
from
"
vuex
"
;
export
default
{
export
default
{
name
:
"
LoginForm.vue
"
,
name
:
"
LoginForm.vue
"
,
...
@@ -113,6 +96,10 @@ export default {
...
@@ -113,6 +96,10 @@ export default {
};
};
},
},
computed
:
mapState
({
token
:
(
state
)
=>
state
.
user
.
token
,
}),
data
()
{
data
()
{
return
{
return
{
message
:
""
,
message
:
""
,
...
@@ -125,18 +112,20 @@ export default {
...
@@ -125,18 +112,20 @@ export default {
},
},
methods
:
{
methods
:
{
/**loginClicked: function (){
this.showError = true;
console.log(this.user.email + " " + this.user.password);
},*/
async
loginClicked
()
{
async
loginClicked
()
{
//alert("You entered, username: " + this.username)
;
this
.
showError
=
true
;
const
loginRequest
=
{
const
loginRequest
=
{
email
:
this
.
user
.
email
,
email
:
this
.
user
.
email
,
password
:
this
.
user
.
password
,
password
:
this
.
user
.
password
,
};
};
const
loginResponse
=
await
doLogin
(
loginRequest
);
const
loginResponse
=
await
doLogin
(
loginRequest
);
if
(
loginResponse
===
"
Failed login
"
)
{
this
.
message
=
"
kunne ikke logge inn
"
;
return
;
}
this
.
$store
.
commit
(
"
saveToken
"
,
loginResponse
);
console
.
log
(
loginResponse
);
console
.
log
(
loginResponse
);
},
},
},
},
...
...
This diff is collapsed.
Click to expand it.
src/store/index.js
+
6
−
1
View file @
1a909050
import
{
createStore
}
from
"
vuex
"
;
import
{
createStore
}
from
"
vuex
"
;
import
user
from
"
./modules/user
"
;
import
createPersistedState
from
"
vuex-persistedstate
"
;
export
default
createStore
({
export
default
createStore
({
state
:
{},
state
:
{},
getters
:
{},
getters
:
{},
mutations
:
{},
mutations
:
{},
actions
:
{},
actions
:
{},
modules
:
{},
modules
:
{
user
,
},
plugins
:
[
createPersistedState
()],
});
});
This diff is collapsed.
Click to expand it.
src/store/modules/user.js
0 → 100644
+
17
−
0
View file @
1a909050
const
state
=
{
token
:
null
,
};
const
mutations
=
{
logout
(
state
)
{
state
.
token
=
null
;
},
saveToken
(
state
,
token
)
{
state
.
token
=
token
;
},
};
export
default
{
state
,
mutations
,
};
This diff is collapsed.
Click to expand it.
src/utils/apiutil.js
+
0
−
8
View file @
1a909050
...
@@ -7,11 +7,3 @@ export function doLogin(loginRequest) {
...
@@ -7,11 +7,3 @@ export function doLogin(loginRequest) {
return
response
.
data
;
return
response
.
data
;
});
});
}
}
export
function
doLoginToken
(
loginRequest
)
{
return
axios
.
post
(
"
http://localhost:8080/server/token
"
,
loginRequest
)
.
then
((
response
)
=>
{
return
response
.
data
;
});
}
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