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
Jérome Perrin
gitlab-ce
Commits
34bf1651
Commit
34bf1651
authored
Jun 14, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable the unlink feature for SAML connected accounts (social login).
parent
27f75cf4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
app/controllers/profiles/accounts_controller.rb
app/controllers/profiles/accounts_controller.rb
+1
-1
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+7
-3
spec/controllers/profiles/accounts_controller_spec.rb
spec/controllers/profiles/accounts_controller_spec.rb
+28
-0
No files found.
app/controllers/profiles/accounts_controller.rb
View file @
34bf1651
...
@@ -5,7 +5,7 @@ class Profiles::AccountsController < Profiles::ApplicationController
...
@@ -5,7 +5,7 @@ class Profiles::AccountsController < Profiles::ApplicationController
def
unlink
def
unlink
provider
=
params
[
:provider
]
provider
=
params
[
:provider
]
current_user
.
identities
.
find_by
(
provider:
provider
).
destroy
current_user
.
identities
.
find_by
(
provider:
provider
).
destroy
unless
provider
.
to_s
==
'saml'
redirect_to
profile_account_path
redirect_to
profile_account_path
end
end
end
end
app/views/profiles/accounts/show.html.haml
View file @
34bf1651
...
@@ -62,10 +62,14 @@
...
@@ -62,10 +62,14 @@
.provider-btn-image
.provider-btn-image
=
provider_image_tag
(
provider
)
=
provider_image_tag
(
provider
)
-
if
auth_active?
(
provider
)
-
if
auth_active?
(
provider
)
=
link_to
unlink_profile_account_path
(
provider:
provider
),
method: :delete
,
class:
'provider-btn'
do
-
if
provider
.
to_s
==
'saml'
Disconnect
%a
.provider-btn
Active
-
else
=
link_to
unlink_profile_account_path
(
provider:
provider
),
method: :delete
,
class:
'provider-btn'
do
Disconnect
-
else
-
else
=
link_to
user_omniauth_authorize_path
(
provider
),
method: :post
,
class:
"provider-btn
#{
'not-active'
if
!
auth_active?
(
provider
)
}
"
,
"data-no-turbolink"
=>
"true"
do
=
link_to
user_omniauth_authorize_path
(
provider
),
method: :post
,
class:
'provider-btn not-active'
,
"data-no-turbolink"
=>
"true"
do
Connect
Connect
%hr
%hr
-
if
current_user
.
can_change_username?
-
if
current_user
.
can_change_username?
...
...
spec/controllers/profiles/accounts_controller_spec.rb
0 → 100644
View file @
34bf1651
require
'spec_helper'
describe
Profiles
::
AccountsController
do
let
(
:user
)
{
create
(
:omniauth_user
,
provider:
'saml'
)
}
before
do
sign_in
(
user
)
end
it
'does not allow to unlink SAML connected account'
do
identity
=
user
.
identities
.
last
delete
:unlink
,
provider:
'saml'
updated_user
=
User
.
find
(
user
.
id
)
expect
(
response
.
status
).
to
eq
(
302
)
expect
(
updated_user
.
identities
.
size
).
to
eq
(
1
)
expect
(
updated_user
.
identities
).
to
include
(
identity
)
end
it
'does allow to delete other linked accounts'
do
user
.
identities
.
create
(
provider:
'twitter'
,
extern_uid:
'twitter_123'
)
expect
{
delete
:unlink
,
provider:
'twitter'
}.
to
change
(
Identity
.
all
,
:size
).
by
(
-
1
)
end
end
\ No newline at end of file
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