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
Merge requests
!20
New password tailwinded
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
New password tailwinded
new_password_fix
into
main
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
Titus Netland
requested to merge
new_password_fix
into
main
3 years ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
59ad5e68
1 commit,
3 years ago
2 files
+
129
−
45
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/components/NewPasswordForm.vue
+
119
−
45
Options
<
template
>
<
template
>
<div>
<div
<v-col
align=
"center"
justify=
"space-around"
class=
"mt-16"
>
class=
"w-full max-w-sm p-6 m-auto bg-white rounded-md shadow-md dark:bg-gray-800"
<v-img
>
max-width=
"45%"
<div
id=
"logoField"
class=
"flex justify-center m-6"
>
:src=
"require('../assets/logo3.svg')"
<img
src=
"../assets/logo3.svg"
alt=
"BoCo logo"
/>
align=
"center"
</div>
<div
id=
"firstPasswordField"
:class=
"
{ error: v$.user.password.$errors.length }"
>
<label
for=
"password"
class=
"block text-sm text-gray-800 dark:text-gray-200"
>
Nytt passord
</label
>
<input
type=
"password"
v-model=
"v$.user.password.$model"
class=
"block w-full px-4 py-2 mt-2 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40"
/>
/>
</v-col>
<!-- error message -->
<div
v-for=
"(error, index) of v$.user.password.$errors"
:key=
"index"
>
<div
class=
"text-red-600 text-sm"
v-show=
"showError"
id=
"passwordErrorId"
>
{{
error
.
$message
}}
</div>
</div>
</div>
<v-form
ref=
"form"
v-model=
"valid"
lazy-validation
class=
"mt-8"
>
<div
<v-text-field
id=
"secondPasswordField"
v-model=
"user.password"
class=
"mt-4"
:rules=
"[rules.required, rules.min]"
:class=
"
{ error: v$.user.rePassword.$errors.length }"
:type=
"'password'"
>
name=
"input-10-1"
<div
class=
"flex items-center justify-between"
>
label=
"Passord"
<label
counter
for=
"rePassword"
></v-text-field>
class=
"block text-sm text-gray-800 dark:text-gray-200"
>
Gjenta nytt passord
</label
>
</div>
<v-text-field
<input
v-model=
"user.rePassword"
type=
"password"
:rules=
"[rules.required, rules.min, rules.passwordConfirmation]"
v-model=
"v$.user.rePassword.$model"
:type=
"'password'"
class=
"block w-full px-4 py-2 mt-2 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 dark:focus:border-blue-300 focus:ring-blue-300 focus:outline-none focus:ring focus:ring-opacity-40"
name=
"input-10-1"
/>
label=
"Confirm Password"
<!-- error message -->
counter
<div
v-for=
"(error, index) of v$.user.rePassword.$errors"
:key=
"index"
>
></v-text-field>
<div
class=
"text-red-600 text-sm"
v-show=
"showError"
id=
"rePasswordErrorId"
>
{{
error
.
$message
}}
</div>
</div>
</div>
<v-col
justify=
"space-around"
align=
"center"
>
<div
id=
"buttonsField"
class=
"mt-6"
>
<v-btn
<button
:disabled=
"!valid"
color=
"success"
class=
"mb-4 mt-4"
width=
"50%"
height=
"40px"
@
click=
"setNewPassword"
@
click=
"setNewPassword"
>
class=
"w-full px-4 py-2 tracking-wide text-white transition-colors duration-200 transform bg-gray-700 rounded-md hover:bg-gray-600 focus:outline-none focus:bg-gray-600"
Endre passord
>
</v-btn>
Endre passord
</
v-col
>
</
button
>
</
v-form
>
</
div
>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
useVuelidate
from
"
@vuelidate/core
"
;
import
{
required
,
minLength
,
sameAs
}
from
"
@vuelidate/validators
"
;
import
{
doNewPassword
}
from
"
@/utils/apiutil
"
;
import
{
mapState
}
from
"
vuex
"
;
export
default
{
export
default
{
name
:
"
NewPasswordForm.vue
"
,
name
:
"
NewPasswordForm.vue
"
,
setup
()
{
return
{
v
$
:
useVuelidate
()
};
},
validations
()
{
return
{
user
:
{
password
:
{
required
,
minLength
:
minLength
(
8
),
},
rePassword
:
{
required
,
minLength
:
minLength
(
8
),
sameAs
:
sameAs
(
this
.
user
.
password
),
},
},
};
},
data
()
{
data
()
{
return
{
return
{
user
:
{
user
:
{
@@ -54,18 +107,39 @@ export default {
@@ -54,18 +107,39 @@ export default {
rePassword
:
""
,
rePassword
:
""
,
},
},
valid
:
true
,
showError
:
false
,
rules
:
{
required
:
(
value
)
=>
!!
value
||
"
Feltet er påkrevd
"
,
min
:
(
v
)
=>
v
.
length
>=
8
||
"
Minimum 8 tegn
"
,
passwordConfirmation
:
(
v
)
=>
v
===
this
.
user
.
password
||
"
Passordene må være like
"
,
},
};
};
},
},
computed
:
mapState
({
token
:
(
state
)
=>
state
.
user
.
token
,
}),
methods
:
{
methods
:
{
async
setNewPassword
()
{},
async
setNewPassword
()
{
this
.
showError
=
true
;
this
.
v$
.
user
.
$touch
();
if
(
this
.
v$
.
user
.
$invalid
)
{
console
.
log
(
"
Invalid, exiting...
"
);
return
;
}
const
newPasswordInfo
=
{
token
:
this
.
token
,
newPassword
:
this
.
password
,
};
const
newPasswordResponse
=
doNewPassword
(
newPasswordInfo
);
if
(
newPasswordResponse
.
newPasswordSet
===
true
)
{
console
.
log
(
"
New password set
"
);
await
this
.
$router
.
push
(
"
/endre
"
);
}
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
();
},
},
Loading