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
59ad5e68
Commit
59ad5e68
authored
2 years ago
by
Titus Netland
Browse files
Options
Downloads
Patches
Plain Diff
New password tailwinded
parent
ce6de1ce
No related branches found
Branches containing commit
No related tags found
1 merge request
!20
New password tailwinded
Pipeline
#176261
passed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/NewPasswordForm.vue
+119
-45
119 additions, 45 deletions
src/components/NewPasswordForm.vue
src/utils/apiutil.js
+10
-0
10 additions, 0 deletions
src/utils/apiutil.js
with
129 additions
and
45 deletions
src/components/NewPasswordForm.vue
+
119
−
45
View file @
59ad5e68
<
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
();
},
},
...
...
This diff is collapsed.
Click to expand it.
src/utils/apiutil.js
+
10
−
0
View file @
59ad5e68
...
@@ -71,3 +71,13 @@ export function getOwnerRating(userid) {
...
@@ -71,3 +71,13 @@ export function getOwnerRating(userid) {
console
.
error
(
error
);
console
.
error
(
error
);
});
});
}
}
export
function
doNewPassword
()
{
//m
//add newPasswordInfo to input
const
auth
=
{
newPasswordSet
:
false
};
//return axios
//.post(API_URL + "newPassword", newPasswordInfo)
//.then((response) => {auth.newPasswordSet = true;return auth;})
//.catch((error) => {console.log(error);return auth;});
return
auth
;
//remove after axios is added
}
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