Skip to content

Commit ce14b98

Browse files
authored
core&ui: add login methods to response body (#1165)
1 parent bbd7fbc commit ce14b98

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

packages/hydrooj/src/handler/home.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class HomeSecurityHandler extends Handler {
204204
])),
205205
geoipProvider: this.ctx.get('geoip')?.provider,
206206
relations,
207+
loginMethods: this.loginMethods,
207208
};
208209
}
209210

packages/hydrooj/src/handler/user.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ class UserLoginHandler extends Handler {
4848

4949
async get() {
5050
this.response.template = 'user_login.html';
51-
this.response.body.loginMethods = this.loginMethods;
51+
this.response.body = {
52+
builtInLogin: system.get('server.login'),
53+
loginMethods: this.loginMethods,
54+
};
5255
}
5356

5457
@param('uname', Types.Username)

packages/ui-default/templates/home_security.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h1 class="section__title" id="linked-accounts" data-heading>{{ _('Linked Accoun
7070
<form method="post">
7171
<input type="hidden" name="operation" value="unlink_account">
7272
{%- for relation in relations -%}{% if relation.platform != 'mail' %}
73-
{% set platform = handler.loginMethods.find(eval("r => r.id === '" + relation.platform + "'")) %}
73+
{% set platform = loginMethods.find(eval("r => r.id === '" + relation.platform + "'")) %}
7474
<li class="platform-list__item">
7575
<div class="media">
7676
{% if platform.icon %}
@@ -88,7 +88,7 @@ <h1 class="section__title" id="linked-accounts" data-heading>{{ _('Linked Accoun
8888
</form>
8989
<form method="post">
9090
<input type="hidden" name="operation" value="link_account">
91-
{%- for method in handler.loginMethods -%}
91+
{%- for method in loginMethods -%}
9292
{%- if not relations.some(eval("r => r.platform === '" + method.id + "'")) -%}
9393
<li class="platform-list__item">
9494
<div class="media">

packages/ui-default/templates/partials/login_dialog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1 class="dialog--signin__title">{{ _('SIGN IN') }}</h1>
4040
<input type="submit" value="{{ _('Login') }}" name="login_submit" class="expanded rounded primary button">
4141
</div></div>
4242
{% endif %}
43-
{%- for v in handler.loginMethods -%}
43+
{%- for v in loginMethods -%}
4444
<div class="row"><div class="columns">
4545
<a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button">{{ _(v.text) }}</a>
4646
</div></div>

packages/ui-default/templates/user_login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1>{{ _('Login') }}</h1>
3030
</div>
3131
</div></div>
3232
{% endif %}
33-
{%- for v in handler.loginMethods -%}
33+
{%- for v in loginMethods -%}
3434
<div class="row"><div class="columns">
3535
<a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button inverse">{{ _(v.text) }}</a>
3636
</div></div>

0 commit comments

Comments
 (0)