mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 01:30:23 +01:00
feat(sign-in): メールアドレスログインを実装 (MisskeyIO#836)
Co-authored-by: まっちゃてぃー。 <56515516+mattyatea@users.noreply.github.com>
This commit is contained in:
parent
3c81926f71
commit
4cb1773147
1 changed files with 17 additions and 11 deletions
|
@ -13,7 +13,6 @@ import type {
|
||||||
SigninsRepository,
|
SigninsRepository,
|
||||||
UserProfilesRepository,
|
UserProfilesRepository,
|
||||||
UserSecurityKeysRepository,
|
UserSecurityKeysRepository,
|
||||||
UsersRepository,
|
|
||||||
} from '@/models/_.js';
|
} from '@/models/_.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { getIpHash } from '@/misc/get-ip-hash.js';
|
import { getIpHash } from '@/misc/get-ip-hash.js';
|
||||||
|
@ -38,9 +37,6 @@ export class SigninApiService {
|
||||||
@Inject(DI.meta)
|
@Inject(DI.meta)
|
||||||
private meta: MiMeta,
|
private meta: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
|
||||||
private usersRepository: UsersRepository,
|
|
||||||
|
|
||||||
@Inject(DI.userProfilesRepository)
|
@Inject(DI.userProfilesRepository)
|
||||||
private userProfilesRepository: UserProfilesRepository,
|
private userProfilesRepository: UserProfilesRepository,
|
||||||
|
|
||||||
|
@ -114,12 +110,24 @@ export class SigninApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch user
|
// Fetch user
|
||||||
const user = await this.usersRepository.findOneBy({
|
const profile = await this.userProfilesRepository.findOne({
|
||||||
usernameLower: username.toLowerCase(),
|
relations: ['user'],
|
||||||
host: IsNull(),
|
where: username.includes('@') ? {
|
||||||
}) as MiLocalUser;
|
email: username,
|
||||||
|
emailVerified: true,
|
||||||
|
user: {
|
||||||
|
host: IsNull(),
|
||||||
|
}
|
||||||
|
} : {
|
||||||
|
user: {
|
||||||
|
usernameLower: username.toLowerCase(),
|
||||||
|
host: IsNull(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const user = (profile?.user as MiLocalUser) ?? null;
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null || profile == null) {
|
||||||
return error(404, {
|
return error(404, {
|
||||||
id: '6cc579cc-885d-43d8-95c2-b8c7fc963280',
|
id: '6cc579cc-885d-43d8-95c2-b8c7fc963280',
|
||||||
});
|
});
|
||||||
|
@ -130,8 +138,6 @@ export class SigninApiService {
|
||||||
id: 'e03a5f46-d309-4865-9b69-56282d94e1eb',
|
id: 'e03a5f46-d309-4865-9b69-56282d94e1eb',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
|
|
||||||
const securityKeysAvailable = await this.userSecurityKeysRepository.countBy({ userId: user.id }).then(result => result >= 1);
|
const securityKeysAvailable = await this.userSecurityKeysRepository.countBy({ userId: user.id }).then(result => result >= 1);
|
||||||
|
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
|
|
Loading…
Reference in a new issue