Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
026f9da0
Unverified
Commit
026f9da0
authored
5 years ago
by
Daniel García
Browse files
Options
Downloads
Patches
Plain Diff
Allow removing users two factors
parent
d23d4f2c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/admin.rs
+13
-0
13 additions, 0 deletions
src/api/admin.rs
src/api/core/two_factor.rs
+1
-3
1 addition, 3 deletions
src/api/core/two_factor.rs
src/static/templates/admin/page.hbs
+13
-3
13 additions, 3 deletions
src/static/templates/admin/page.hbs
with
27 additions
and
6 deletions
src/api/admin.rs
+
13
−
0
View file @
026f9da0
...
...
@@ -28,6 +28,7 @@ pub fn routes() -> Vec<Route> {
invite_user
,
delete_user
,
deauth_user
,
remove_2fa
,
update_revision_users
,
post_config
,
delete_config
,
...
...
@@ -196,6 +197,18 @@ fn deauth_user(uuid: String, _token: AdminToken, conn: DbConn) -> EmptyResult {
user
.save
(
&
conn
)
}
#[post(
"/users/<uuid>/remove-2fa"
)]
fn
remove_2fa
(
uuid
:
String
,
_token
:
AdminToken
,
conn
:
DbConn
)
->
EmptyResult
{
let
mut
user
=
match
User
::
find_by_uuid
(
&
uuid
,
&
conn
)
{
Some
(
user
)
=>
user
,
None
=>
err!
(
"User doesn't exist"
),
};
TwoFactor
::
delete_all_by_user
(
&
user
.uuid
,
&
conn
)
?
;
user
.totp_recover
=
None
;
user
.save
(
&
conn
)
}
#[post(
"/users/update_revision"
)]
fn
update_revision_users
(
_token
:
AdminToken
,
conn
:
DbConn
)
->
EmptyResult
{
User
::
update_all_revisions
(
&
conn
)
...
...
This diff is collapsed.
Click to expand it.
src/api/core/two_factor.rs
+
1
−
3
View file @
026f9da0
...
...
@@ -95,9 +95,7 @@ fn recover(data: JsonUpcase<RecoverTwoFactor>, conn: DbConn) -> JsonResult {
}
// Remove all twofactors from the user
for
twofactor
in
TwoFactor
::
find_by_user
(
&
user
.uuid
,
&
conn
)
{
twofactor
.delete
(
&
conn
)
?
;
}
TwoFactor
::
delete_all_by_user
(
&
user
.uuid
,
&
conn
)
?
;
// Remove the recovery code, not needed without twofactors
user
.totp_recover
=
None
;
...
...
This diff is collapsed.
Click to expand it.
src/static/templates/admin/page.hbs
+
13
−
3
View file @
026f9da0
...
...
@@ -26,9 +26,13 @@
{{/
each
}}
</span>
</div>
<div
style=
"flex: 0 0 240px;"
>
<a
class=
"mr-3"
href=
"#"
onclick=
'deauthUser(
{{
jsesc
Id
}}
)'
>
Deauthorize sessions
</a>
<a
class=
"mr-3"
href=
"#"
onclick=
'deleteUser(
{{
jsesc
Id
}}
,
{{
jsesc
Email
}}
)'
>
Delete User
</a>
<div
style=
"flex: 0 0 300px; font-size: 90%; text-align: right; padding-right: 15px"
>
{{#if
TwoFactorEnabled
}}
<a
class=
"mr-2"
href=
"#"
onclick=
'remove2fa(
{{
jsesc
Id
}}
)'
>
Remove all 2FA
</a>
{{/if}}
<a
class=
"mr-2"
href=
"#"
onclick=
'deauthUser(
{{
jsesc
Id
}}
)'
>
Deauthorize sessions
</a>
<a
class=
"mr-2"
href=
"#"
onclick=
'deleteUser(
{{
jsesc
Id
}}
,
{{
jsesc
Email
}}
)'
>
Delete User
</a>
</div>
</div>
</div>
...
...
@@ -227,6 +231,12 @@
}
return
false
;
}
function
remove2fa
(
id
)
{
_post
(
"
/admin/users/
"
+
id
+
"
/remove-2fa
"
,
"
2FA removed correctly
"
,
"
Error removing 2FA
"
);
return
false
;
}
function
deauthUser
(
id
)
{
_post
(
"
/admin/users/
"
+
id
+
"
/deauth
"
,
"
Sessions deauthorized correctly
"
,
...
...
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