Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
7cb86eb3
Commit
7cb86eb3
authored
May 24, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont allow LDAP users to change password inside GitLab
parent
bd6dfe7d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
34 deletions
+48
-34
app/controllers/profiles_controller.rb
app/controllers/profiles_controller.rb
+12
-3
app/models/user.rb
app/models/user.rb
+4
-0
app/views/profiles/account.html.haml
app/views/profiles/account.html.haml
+32
-31
No files found.
app/controllers/profiles_controller.rb
View file @
7cb86eb3
...
@@ -2,6 +2,9 @@ class ProfilesController < ApplicationController
...
@@ -2,6 +2,9 @@ class ProfilesController < ApplicationController
include
ActionView
::
Helpers
::
SanitizeHelper
include
ActionView
::
Helpers
::
SanitizeHelper
before_filter
:user
before_filter
:user
before_filter
:authorize_change_password!
,
only: :update_password
before_filter
:authorize_change_username!
,
only: :update_username
layout
'profile'
layout
'profile'
def
show
def
show
...
@@ -53,9 +56,7 @@ class ProfilesController < ApplicationController
...
@@ -53,9 +56,7 @@ class ProfilesController < ApplicationController
end
end
def
update_username
def
update_username
if
@user
.
can_change_username?
@user
.
update_attributes
(
username:
params
[
:user
][
:username
])
@user
.
update_attributes
(
username:
params
[
:user
][
:username
])
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
format
.
js
...
@@ -80,4 +81,12 @@ class ProfilesController < ApplicationController
...
@@ -80,4 +81,12 @@ class ProfilesController < ApplicationController
user_attributes
user_attributes
end
end
def
authorize_change_password!
return
render_404
if
@user
.
ldap_user?
end
def
authorize_change_username!
return
render_404
unless
@user
.
can_change_username?
end
end
end
app/models/user.rb
View file @
7cb86eb3
...
@@ -340,4 +340,8 @@ class User < ActiveRecord::Base
...
@@ -340,4 +340,8 @@ class User < ActiveRecord::Base
nil
nil
end
end
end
end
def
ldap_user?
extern_uid
&&
provider
==
'ldap'
end
end
end
app/views/profiles/account.html.haml
View file @
7cb86eb3
-
if
Gitlab
.
config
.
omniauth
.
enabled
-
unless
current_user
.
ldap_user?
%fieldset
-
if
Gitlab
.
config
.
omniauth
.
enabled
%legend
Social Accounts
%fieldset
.oauth_select_holder
%legend
Social Accounts
%p
.hint
Tip: Click on icon to activate sigin with one of the following services
.oauth_select_holder
-
User
.
omniauth_providers
.
each
do
|
provider
|
%p
.hint
Tip: Click on icon to activate sigin with one of the following services
%span
{
class:
oauth_active_class
(
provider
)
}
-
User
.
omniauth_providers
.
each
do
|
provider
|
=
link_to
authbutton
(
provider
,
32
),
omniauth_authorize_path
(
User
,
provider
)
%span
{
class:
oauth_active_class
(
provider
)
}
=
link_to
authbutton
(
provider
,
32
),
omniauth_authorize_path
(
User
,
provider
)
%fieldset
.update-password
%legend
Password
=
form_for
@user
,
url:
update_password_profile_path
,
method: :put
do
|
f
|
.padded
%p
.slead
After successful password update you will be redirected to login page where you should login with new password
-
if
@user
.
errors
.
any?
.alert.alert-error
%ul
-
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.clearfix
=
f
.
label
:password
.input
=
f
.
password_field
:password
,
required:
true
.clearfix
=
f
.
label
:password_confirmation
.input
=
f
.
password_field
:password_confirmation
,
required:
true
.clearfix
.input
=
f
.
submit
'Save password'
,
class:
"btn btn-save"
...
@@ -29,29 +53,6 @@
...
@@ -29,29 +53,6 @@
%span
You don`t have one yet. Click generate to fix it.
%span
You don`t have one yet. Click generate to fix it.
=
f
.
submit
'Generate'
,
class:
"btn success btn-build-token"
=
f
.
submit
'Generate'
,
class:
"btn success btn-build-token"
%fieldset
.update-password
%legend
Password
=
form_for
@user
,
url:
update_password_profile_path
,
method: :put
do
|
f
|
.padded
%p
.slead
After successful password update you will be redirected to login page where you should login with new password
-
if
@user
.
errors
.
any?
.alert.alert-error
%ul
-
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.clearfix
=
f
.
label
:password
.input
=
f
.
password_field
:password
,
required:
true
.clearfix
=
f
.
label
:password_confirmation
.input
=
f
.
password_field
:password_confirmation
,
required:
true
.clearfix
.input
=
f
.
submit
'Save password'
,
class:
"btn btn-save"
-
if
current_user
.
can_change_username?
-
if
current_user
.
can_change_username?
%fieldset
.update-username
%fieldset
.update-username
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment