Commit 0a795d8 1 parent 7d28892 commit 0a795d8 Copy full SHA for 0a795d8
File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,17 @@ <h1>Not Found</h1>
103
103
even if there is no given user, give < code > error=ignore</ code > option into
104
104
request.</ p >
105
105
106
+ < h3 > Request the user information</ h3 >
107
+ < p > If you need the information of given user when the authentication has
108
+ succeed, give < code > with=userinfo</ code > option into request.</ p >
109
+
110
+ < h3 > Response example: when < code > with=userinfo</ code > option was given</ h3 >
111
+ < pre > HTTP/1.1 200 OK
112
+ Vary: Accept
113
+ Content-Type: application/json
114
+
115
+ {{ require('langdev.web.serializers').json(current_user) }}</ pre >
116
+
106
117
< h2 > Delete</ h2 >
107
118
{% call render_raw_form('delete_app', app_key=app.key) %}
108
119
< input type ="submit " value ="Delete " />
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ def delete_app(app_key):
87
87
def sso (app_key , user_login ):
88
88
"""Simple SSO API."""
89
89
app = get_app (app_key )
90
+ require_userinfo = request .values .get ('with' ) == 'userinfo'
90
91
error_ignored = request .values .get ('error' ) == 'ignore'
91
92
success = None
92
93
if User .LOGIN_PATTERN .match (user_login ):
@@ -108,5 +109,12 @@ def sso(app_key, user_login):
108
109
success = False
109
110
if success is None :
110
111
success = app .hmac (user .password ) == request .values ['password' ]
111
- return render ('thirdparty/sso' , success , success = success )
112
+ if success and require_userinfo :
113
+ result = user
114
+ # workaround to include ``email`` attribute in the response.
115
+ # see also :func:`langdev.objsimplify.transform`.
116
+ g .current_user = user
117
+ else :
118
+ result = success
119
+ return render ('thirdparty/sso' , result , success = success )
112
120
You can’t perform that action at this time.
0 commit comments