diff --git a/README.md b/README.md index 2f6fa463..46b613a1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Authorization code flow: -http://sl-server:7777/oauth/authorize?client_id=client-id&state=123456&response_type=code&redirect_uri=http%3A%2F%2Fsl-client%3A7000%2Fcallback&state=dvoQ6Jtv0PV68tBUgUMM035oFiZw57 +http://sl-server:7777/oauth/authorize?client_id=client-id&state=123456&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A7000%2Fcallback&state=dvoQ6Jtv0PV68tBUgUMM035oFiZw57 Implicit flow: http://sl-server:7777/oauth/authorize?client_id=client-id&state=123456&response_type=token&redirect_uri=http%3A%2F%2Fsl-client%3A7000%2Fcallback&state=dvoQ6Jtv0PV68tBUgUMM035oFiZw57 diff --git a/app/models.py b/app/models.py index 4acbafe9..b8883efa 100644 --- a/app/models.py +++ b/app/models.py @@ -446,7 +446,12 @@ class ClientUser(db.Model, ModelMixin): res[Scope.NAME.value] = self.user.name elif scope == Scope.AVATAR_URL: if self.user.profile_picture_id: - res[Scope.AVATAR_URL.value] = self.user.profile_picture.get_url() + if self.default_avatar: + res[Scope.AVATAR_URL.value] = URL + "/static/default-avatar.png" + else: + res[ + Scope.AVATAR_URL.value + ] = self.user.profile_picture.get_url() else: res[Scope.AVATAR_URL.value] = None elif scope == Scope.EMAIL: diff --git a/app/oauth/templates/oauth/authorize.html b/app/oauth/templates/oauth/authorize.html index 9970a61d..be1806d6 100644 --- a/app/oauth/templates/oauth/authorize.html +++ b/app/oauth/templates/oauth/authorize.html @@ -4,6 +4,33 @@ Authorization {% endblock %} +{% block head %} + +{% endblock %} + {% block default_content %}
@@ -43,6 +70,9 @@
{{ client.name }} will receive the following info +
+ You can customize the information sent to this app. +
@@ -95,19 +125,26 @@
- {% if current_user.profile_picture_id %} -
-
- +
+
+
-
- +
+ + +
OR
+ +
{% endif %} - - {% endif %} {% if client_user %} diff --git a/app/oauth/views/authorize.py b/app/oauth/views/authorize.py index 38fae020..366b46fb 100644 --- a/app/oauth/views/authorize.py +++ b/app/oauth/views/authorize.py @@ -122,6 +122,8 @@ def authorize(): suggested_name = request.form.get("suggested-name") custom_name = request.form.get("custom-name") + use_default_avatar = request.form.get("avatar-choice") == "default" + gen_email = None if custom_email_prefix: # check if user can generate custom email @@ -167,6 +169,11 @@ def authorize(): ) client_user.name = suggested_name + if use_default_avatar: + # use default avatar + LOG.d("use default avatar for user %s client %s", current_user, client) + client_user.default_avatar = True + db.session.flush() LOG.d("create client-user for client %s, user %s", client, current_user) diff --git a/static/default-avatar.png b/static/default-avatar.png index 058b3167..a6700977 100644 Binary files a/static/default-avatar.png and b/static/default-avatar.png differ diff --git a/static/style.css b/static/style.css index 17eedd24..893f477f 100644 --- a/static/style.css +++ b/static/style.css @@ -28,5 +28,16 @@ /* round the edges to a circle with border radius 1/2 container size */ border-radius: 10%; + margin-top: 10px; +} + +.small-profile-picture { + /* make a square container */ + width: 60px; + height: 60px; + + /* round the edges to a circle with border radius 1/2 container size */ + border-radius: 50%; + margin-top: 10px; } \ No newline at end of file