Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iric-data
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
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
bioinfo_iric
iric-data
Merge requests
!80
Resolve "lab association not done when logging in with token"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "lab association not done when logging in with token"
152-lab-association-not-done-when-logging-in-with-token
into
master
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
Jonathan Séguin
requested to merge
152-lab-association-not-done-when-logging-in-with-token
into
master
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Expand
Closes
#152 (closed)
Edited
2 years ago
by
Jonathan Séguin
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
749b844a
1 commit,
2 years ago
3 files
+
29
−
27
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
portal/views/secure/login_success.py
+
0
−
26
Options
@@ -8,34 +8,8 @@ from ...models import Lab
class
LoginSuccess
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
"""
Update user association with IRIC labs and redirect to appropriate dashboard
External lab associations are to be managed manually
"""
user
=
self
.
request
.
user
if
user
.
is_anonymous
:
return
redirect
(
'
login
'
)
azuread_data
=
{}
try
:
azuread_data
=
user
.
social_auth
.
get
(
provider
=
'
azuread-tenant-oauth2
'
).
extra_data
except
:
pass
azuread_groups
=
azuread_data
[
'
groups
'
]
if
'
groups
'
in
azuread_data
else
None
azuread_samaccountname
=
azuread_data
[
'
onPremisesSamAccountName
'
]
if
'
onPremisesSamAccountName
'
in
azuread_data
else
None
if
azuread_samaccountname
and
not
user
.
profile
.
accountname
:
user
.
profile
.
accountname
=
azuread_samaccountname
if
hasattr
(
user
,
'
ldapuser
'
)
or
azuread_groups
:
user
.
profile
.
labs
.
remove
(
*
Lab
.
objects
.
filter
(
ldap__startswith
=
'
iric-
'
))
if
hasattr
(
user
,
'
ldapuser
'
):
user
.
profile
.
labs
.
add
(
*
Lab
.
objects
.
filter
(
ldap__in
=
user
.
ldap_user
.
group_names
))
elif
azuread_groups
:
user
.
profile
.
labs
.
add
(
*
Lab
.
objects
.
filter
(
ldap__in
=
azuread_groups
))
if
self
.
request
.
user
.
is_staff
:
# user is an admin
request
.
session
[
'
active_lab_id
'
]
=
Lab
.
objects
.
get
(
ldap
=
settings
.
AUTH_LDAP_STAFF_GROUP
.
split
(
'
,
'
)[
0
][
3
:]).
id
Loading