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
51f26556
Commit
51f26556
authored
3 years ago
by
Håkon Eilertsen Røskaft
Browse files
Options
Downloads
Patches
Plain Diff
Added the old password field to new password form
parent
18585c62
No related branches found
No related tags found
1 merge request
!92
Change password 2
Pipeline
#180146
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/FormComponents/NewPasswordForm.vue
+51
-18
51 additions, 18 deletions
src/components/FormComponents/NewPasswordForm.vue
src/utils/apiutil.js
+7
-3
7 additions, 3 deletions
src/utils/apiutil.js
with
58 additions
and
21 deletions
src/components/FormComponents/NewPasswordForm.vue
+
51
−
18
View file @
51f26556
...
@@ -8,8 +8,35 @@
...
@@ -8,8 +8,35 @@
Endre passord
Endre passord
</h3>
</h3>
<div
id=
"oldPasswordField"
:class=
"
{ error: v$.user.oldPassword.$errors.length }"
>
<label
for=
"oldPassword"
class=
"block text-sm text-gray-800 dark:text-gray-200"
>
Gammelt passord
</label
>
<input
type=
"password"
v-model=
"v$.user.oldPassword.$model"
class=
"block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-blue-300"
/>
<!-- error message -->
<div
v-for=
"(error, index) of v$.user.oldPassword.$errors"
:key=
"index"
>
<div
class=
"text-red-600 text-sm"
v-show=
"showError"
id=
"oldPasswordErrorId"
>
{{
error
.
$message
}}
</div>
</div>
</div>
<div
<div
id=
"firstPasswordField"
id=
"firstPasswordField"
class=
"mt-4"
:class=
"
{ error: v$.user.password.$errors.length }"
:class=
"
{ error: v$.user.password.$errors.length }"
>
>
<label
<label
...
@@ -71,6 +98,12 @@
...
@@ -71,6 +98,12 @@
:text=
"'Sett ny passord'"
:text=
"'Sett ny passord'"
/>
/>
</div>
</div>
<div
class=
"flex items-center justify-center text-center bg-gray-50"
>
<label
class=
"mx-2 text-sm font-bold text-red-500 dark:text-primary-light hover:underline"
>
{{
message
}}
</label
>
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -93,6 +126,9 @@ export default {
...
@@ -93,6 +126,9 @@ export default {
validations
()
{
validations
()
{
return
{
return
{
user
:
{
user
:
{
oldPassword
:
{
required
:
helpers
.
withMessage
(
`Feltet må være utfylt`
,
required
),
},
password
:
{
password
:
{
required
:
helpers
.
withMessage
(
`Feltet må være utfylt`
,
required
),
required
:
helpers
.
withMessage
(
`Feltet må være utfylt`
,
required
),
minLength
:
helpers
.
withMessage
(
minLength
:
helpers
.
withMessage
(
...
@@ -112,7 +148,9 @@ export default {
...
@@ -112,7 +148,9 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
message
:
""
,
user
:
{
user
:
{
oldPassword
:
""
,
password
:
""
,
password
:
""
,
rePassword
:
""
,
rePassword
:
""
,
},
},
...
@@ -134,30 +172,25 @@ export default {
...
@@ -134,30 +172,25 @@ export default {
return
;
return
;
}
}
const
newPassword
=
this
.
user
.
password
;
const
newPassword
=
{
newPassword
:
this
.
user
.
password
,
oldPassword
:
this
.
user
.
oldPassword
,
};
const
newPasswordResponse
=
await
doNewPassword
(
newPassword
);
const
newPasswordResponse
=
await
doNewPassword
(
newPassword
);
if
(
newPasswordResponse
!=
null
)
{
if
(
newPasswordResponse
.
correctPassword
)
{
console
.
log
(
"
New password set
"
);
//New password was set
this
.
$store
.
commit
(
"
saveToken
"
,
newPasswordResponse
);
this
.
message
=
""
;
this
.
$store
.
commit
(
"
saveToken
"
,
newPasswordResponse
.
token
);
await
this
.
$router
.
push
(
"
/
"
);
await
this
.
$router
.
push
(
"
/
"
);
}
else
if
(
!
newPasswordResponse
.
correctPassword
){
//The old password was not correct
this
.
message
=
"
Det gamle passordet stemmer ikke for denne brukeren
"
;
}
else
{
}
else
{
console
.
log
(
"
Couldn't set new password
"
);
//Ops something went wrong
this
.
message
=
"
Ops noe gikk galt
"
;
}
}
/*
if (newPasswordResponse.newPasswordSet === true) {
console.log("New password set");
await this.$router.push("/");
} else if (newPasswordResponse.newPasswordSet === false) {
console.log("Couldn't set new password");
} else {
console.log("Something went wrong");
}
*/
},
},
validate
()
{
validate
()
{
this
.
$refs
.
form
.
validate
();
this
.
$refs
.
form
.
validate
();
...
...
This diff is collapsed.
Click to expand it.
src/utils/apiutil.js
+
7
−
3
View file @
51f26556
...
@@ -85,21 +85,25 @@ export function getAverageRating(userid) {
...
@@ -85,21 +85,25 @@ export function getAverageRating(userid) {
});
});
}
}
export
async
function
doNewPassword
(
password
)
{
export
async
function
doNewPassword
(
password
)
{
const
auth
=
{
correctPassword
:
false
,
token
:
""
};
let
res
=
await
axios
({
let
res
=
await
axios
({
method
:
"
put
"
,
method
:
"
put
"
,
url
:
API_URL
+
"
user/p
rofile/p
assword
"
,
url
:
API_URL
+
"
user/password
/change
"
,
headers
:
tokenHeader
(),
headers
:
tokenHeader
(),
data
:
{
data
:
{
password
:
password
,
password
:
password
,
},
},
})
})
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
return
response
;
auth
.
correctPassword
=
true
;
auth
.
token
=
response
.
data
;
return
auth
;
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
error
);
console
.
log
(
error
);
return
auth
;
});
});
return
res
.
data
;
return
res
;
}
}
export
function
postNewItem
(
itemInfo
)
{
export
function
postNewItem
(
itemInfo
)
{
...
...
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