Skip to content

Commit c25c1d5

Browse files
authored
fix #1202 (#1203)
1 parent f9fb8dc commit c25c1d5

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/hydrooj/src/handler/user.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,12 @@ class UserRegisterWithCodeHandler extends Handler {
303303
}
304304

305305
async get() {
306+
const provider = this.ctx.oauth.providers[this.tdoc.identity.provider];
306307
this.response.template = 'user_register_with_code.html';
307-
this.response.body = this.tdoc;
308+
this.response.body = {
309+
...this.tdoc,
310+
lockUsername: !!provider?.lockUsername,
311+
};
308312
}
309313

310314
@param('password', Types.Password)
@@ -317,7 +321,7 @@ class UserRegisterWithCodeHandler extends Handler {
317321
) {
318322
const provider = this.ctx.oauth.providers[this.tdoc.identity.provider];
319323
if (!provider) throw new SystemError(`OAuth provider ${this.tdoc.identity.provider} not found`);
320-
if (provider.lockUsername) uname = this.tdoc.identity.username;
324+
if (provider.lockUsername) uname = this.tdoc.username;
321325
if (!Types.Username[1](uname)) throw new ValidationError('uname');
322326
if (password !== verify) throw new VerifyPasswordError();
323327
const randomEmail = `${randomstring(12)}@invalid.local`; // some random email to remove in the future

packages/ui-default/templates/user_register_with_code.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ <h1>{{ _('Sign Up') }}</h1>
1212
<div>
1313
<label class="inverse material textbox">
1414
{{ _('Username') }}
15-
<input name="uname" value="{{ username or '' }}" type="text" autofocus>
15+
<input name="uname" value="{{ username or '' }}" type="text" {% if lockUsername %}readonly{% else %}autofocus{% endif %}>
1616
</label>
1717
</div>
1818
<div>
1919
<label class="inverse material textbox">
2020
{{ _('Password') }}
21-
<input name="password" type="password">
21+
<input name="password" type="password" {% if lockUsername %}autofocus{% endif %}>
2222
</label>
2323
</div>
2424
<div>

0 commit comments

Comments
 (0)