Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
ddd6b042
Commit
ddd6b042
authored
11 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
convert to oauth2 ids
parent
d195f7b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
internimsclient.py
+2
-2
2 additions, 2 deletions
internimsclient.py
nimsapi.py
+3
-3
3 additions, 3 deletions
nimsapi.py
nimsapiutil.py
+1
-1
1 addition, 1 deletion
nimsapiutil.py
with
6 additions
and
6 deletions
internimsclient.py
+
2
−
2
View file @
ddd6b042
...
...
@@ -44,10 +44,10 @@ def update(db, api_uri, site_id, privkey, internims_url):
new_remotes
=
response
[
'
users
'
]
log
.
debug
(
'
users w/ remotes:
'
+
str
(
new_remotes
))
for
user
in
response
[
'
users
'
]:
db
.
users
.
update
({
'
_id
'
:
user
},
{
'
$set
'
:
{
'
remotes
'
:
new_remotes
.
get
(
user
,
[])}})
db
.
users
.
update
({
'
oa2
_id
'
:
user
},
{
'
$set
'
:
{
'
remotes
'
:
new_remotes
.
get
(
user
,
[])}})
# cannot use new_remotes.viewkeys(). leads to 'bson.errors.InvalidDocument: Cannot encode object: dict_keys([])'
db
.
users
.
update
({
'
remotes
'
:
{
'
$exists
'
:
True
},
'
_id
'
:
{
'
$nin
'
:
new_remotes
.
keys
()}},
{
'
$unset
'
:
{
'
remotes
'
:
''
}},
multi
=
True
)
db
.
users
.
update
({
'
remotes
'
:
{
'
$exists
'
:
True
},
'
oa2
_id
'
:
{
'
$nin
'
:
new_remotes
.
keys
()}},
{
'
$unset
'
:
{
'
remotes
'
:
''
}},
multi
=
True
)
else
:
log
.
warning
((
r
.
status_code
,
r
.
reason
))
...
...
This diff is collapsed.
Click to expand it.
nimsapi.py
+
3
−
3
View file @
ddd6b042
...
...
@@ -267,12 +267,12 @@ class User(nimsapiutil.NIMSRequestHandler):
def
get
(
self
,
uid
):
"""
Return User details.
"""
user
=
self
.
app
.
db
.
users
.
find_one
({
'
_id
'
:
uid
})
user
=
self
.
app
.
db
.
users
.
find_one
({
'
oa2
_id
'
:
uid
})
self
.
response
.
write
(
json
.
dumps
(
user
,
default
=
bson
.
json_util
.
default
))
def
put
(
self
,
uid
):
"""
Update an existing User.
"""
user
=
self
.
app
.
db
.
users
.
find_one
({
'
_id
'
:
uid
})
user
=
self
.
app
.
db
.
users
.
find_one
({
'
oa2
_id
'
:
uid
})
if
not
user
:
self
.
abort
(
404
)
if
uid
==
self
.
userid
or
self
.
user_is_superuser
:
# users can only update their own info
...
...
@@ -287,7 +287,7 @@ class User(nimsapiutil.NIMSRequestHandler):
updates
[
'
$set
'
][
k
]
=
False
# superuser is tri-state: False indicates granted, but disabled, superuser privileges
elif
v
.
lower
()
not
in
(
'
1
'
,
'
true
'
):
updates
[
'
$unset
'
][
k
]
=
''
self
.
app
.
db
.
users
.
update
({
'
_id
'
:
uid
},
updates
)
self
.
app
.
db
.
users
.
update
({
'
oa2
_id
'
:
uid
},
updates
)
else
:
self
.
abort
(
403
)
...
...
This diff is collapsed.
Click to expand it.
nimsapiutil.py
+
1
−
1
View file @
ddd6b042
...
...
@@ -53,7 +53,7 @@ class NIMSRequestHandler(webapp2.RequestHandler):
self
.
initialize
(
request
,
response
)
self
.
request
.
remote_user
=
self
.
request
.
get
(
'
user
'
,
None
)
# FIXME: auth system should set REMOTE_USER
self
.
userid
=
self
.
request
.
remote_user
or
'
@public
'
self
.
user
=
self
.
app
.
db
.
users
.
find_one
({
'
_id
'
:
self
.
userid
})
self
.
user
=
self
.
app
.
db
.
users
.
find_one
({
'
oa2
_id
'
:
self
.
userid
})
self
.
user_is_superuser
=
self
.
user
.
get
(
'
superuser
'
)
self
.
target_id
=
self
.
request
.
get
(
'
iid
'
,
None
)
self
.
site_id
=
self
.
app
.
config
[
'
site_id
'
]
...
...
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