Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
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
osuny
Admin
Commits
c94664f1
Unverified
Commit
c94664f1
authored
1 year ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
need current_passwd to update passwd in extranet
parent
3c868dc8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/extranet/account_controller.rb
+23
-12
23 additions, 12 deletions
app/controllers/extranet/account_controller.rb
app/views/extranet/account/edit.html.erb
+25
-1
25 additions, 1 deletion
app/views/extranet/account/edit.html.erb
with
48 additions
and
13 deletions
app/controllers/extranet/account_controller.rb
+
23
−
12
View file @
c94664f1
...
...
@@ -11,28 +11,39 @@ class Extranet::AccountController < Extranet::ApplicationController
end
def
update
manage_password
current_user
.
update
user_params
redirect_to
account_path
,
notice:
t
(
'extranet.account.updated'
)
if
update_user
(
current_user
,
user_params
)
bypass_sign_in
current_user
,
scope: :user
if
sign_in_after_change_password?
redirect_to
account_path
,
notice:
t
(
'extranet.account.updated'
)
else
breadcrumb
add_breadcrumb
t
(
'extranet.account.edit'
)
render
:edit
end
end
protected
def
manage_password
# to prevent cognitive complexity (the bottom block should be in an if condition where password present)
# Password not provided when user from sso
params
[
:user
][
:password
]
||=
''
if
params
[
:user
][
:password
].
blank?
params
[
:user
].
delete
(
:password
)
def
update_user
(
user
,
params
)
if
params
[
:password
].
blank?
params
.
delete
(
:current_password
)
user
.
update_without_password
(
params
)
else
current_user
.
reset_password
(
params
[
:user
][
:
password
],
params
[
:user
][
:password
]
)
user
.
update_with_
password
(
params
)
end
end
def
user_params
params
.
require
(
:user
)
.
permit
(
:first_name
,
:last_name
,
:email
,
:mobile_phone
,
:language_id
,
:password
,
:picture
,
:picture_infos
,
:picture_delete
)
.
permit
(
:first_name
,
:last_name
,
:email
,
:mobile_phone
,
:language_id
,
:current_password
,
:password
,
:password_confirmation
,
:picture
,
:picture_infos
,
:picture_delete
)
end
def
sign_in_after_change_password?
return
true
if
user_params
[
:password
].
blank?
Devise
.
sign_in_after_change_password
end
def
breadcrumb
...
...
This diff is collapsed.
Click to expand it.
app/views/extranet/account/edit.html.erb
+
25
−
1
View file @
c94664f1
...
...
@@ -22,9 +22,23 @@
<div
class=
"col-lg-6"
>
<%=
f
.
input
:email
%>
<%=
f
.
input
:mobile_phone
%>
</div>
</div>
<h3
class=
"mt-5 mb-4"
>
<%=
t
(
"devise.passwords.edit.new"
)
%>
</h3>
<div
class=
"row"
>
<div
class=
"col-lg-6"
>
<%=
f
.
input
:current_password
,
as: :password
,
input_html:
{
autocomplete:
"current-password"
}
%>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6"
>
<%=
f
.
input
:password
,
as: :password_with_hints
,
hint:
t
(
'admin.password_hint'
),
allow_password_uncloaking:
true
,
validators:
{
length:
Devise
.
password_length
.
first
,
...
...
@@ -33,9 +47,19 @@
numeric_char:
true
,
special_char:
Rails
.
application
.
config
.
allowed_special_chars
},
label:
t
(
'devise.passwords.edit.new_password'
),
required:
false
,
input_html:
{
autocomplete:
"new-password"
}
%>
</div>
<div
class=
"col-lg-6"
>
<%=
f
.
input
:password_confirmation
,
as: :password_with_sync
,
allow_password_uncloaking:
true
,
compare_with_field: :password
,
input_html:
{
autocomplete:
"new-password"
}
%>
</div>
</div>
<%=
submit
f
%>
<%
if
current_user
.
visitor?
%>
...
...
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