core&ui: add login methods to response body (#1165)

This commit is contained in:
Baoshuo authored and GitHub committed 2026-05-24 22:52:08 +08:00
1 parent bbd7fbc852
commit ce14b98184
5 files changed
+9 -5

No files matched your search

+1
View File
@@ -204,6 +204,7 @@ class HomeSecurityHandler extends Handler {
])), ])),
geoipProvider: this.ctx.get('geoip')?.provider, geoipProvider: this.ctx.get('geoip')?.provider,
relations, relations,
loginMethods: this.loginMethods,
}; };
} }
+4 -1
View File
@@ -48,7 +48,10 @@ class UserLoginHandler extends Handler {
async get() { async get() {
this.response.template = 'user_login.html'; this.response.template = 'user_login.html';
this.response.body.loginMethods = this.loginMethods; this.response.body = {
builtInLogin: system.get('server.login'),
loginMethods: this.loginMethods,
};
} }
@param('uname', Types.Username) @param('uname', Types.Username)
@@ -70,7 +70,7 @@
<form method="post"> <form method="post">
<input type="hidden" name="operation" value="unlink_account"> <input type="hidden" name="operation" value="unlink_account">
{%- for relation in relations -%}{% if relation.platform != 'mail' %} {%- for relation in relations -%}{% if relation.platform != 'mail' %}
{% set platform = handler.loginMethods.find(eval("r => r.id === '" + relation.platform + "'")) %} {% set platform = loginMethods.find(eval("r => r.id === '" + relation.platform + "'")) %}
<li class="platform-list__item"> <li class="platform-list__item">
<div class="media"> <div class="media">
{% if platform.icon %} {% if platform.icon %}
@@ -88,7 +88,7 @@
</form> </form>
<form method="post"> <form method="post">
<input type="hidden" name="operation" value="link_account"> <input type="hidden" name="operation" value="link_account">
{%- for method in handler.loginMethods -%} {%- for method in loginMethods -%}
{%- if not relations.some(eval("r => r.platform === '" + method.id + "'")) -%} {%- if not relations.some(eval("r => r.platform === '" + method.id + "'")) -%}
<li class="platform-list__item"> <li class="platform-list__item">
<div class="media"> <div class="media">
@@ -40,7 +40,7 @@
<input type="submit" value="{{ _('Login') }}" name="login_submit" class="expanded rounded primary button"> <input type="submit" value="{{ _('Login') }}" name="login_submit" class="expanded rounded primary button">
</div></div> </div></div>
{% endif %} {% endif %}
{%- for v in handler.loginMethods -%} {%- for v in loginMethods -%}
<div class="row"><div class="columns"> <div class="row"><div class="columns">
<a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button">{{ _(v.text) }}</a> <a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button">{{ _(v.text) }}</a>
</div></div> </div></div>
@@ -30,7 +30,7 @@
</div> </div>
</div></div> </div></div>
{% endif %} {% endif %}
{%- for v in handler.loginMethods -%} {%- for v in loginMethods -%}
<div class="row"><div class="columns"> <div class="row"><div class="columns">
<a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button inverse">{{ _(v.text) }}</a> <a href="{{ url('user_oauth', type=v.id) }}" class="expanded rounded button inverse">{{ _(v.text) }}</a>
</div></div> </div></div>