mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
chore: remove deleteByEmail
This commit is contained in:
@@ -22,10 +22,6 @@ export class OAuthLinkTokenRepository {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteByEmail(userEmail: string) {
|
|
||||||
await this.db.deleteFrom('oauth_link_token').where('userEmail', '=', userEmail).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async cleanup() {
|
async cleanup() {
|
||||||
const result = await this.db
|
const result = await this.db
|
||||||
.deleteFrom('oauth_link_token')
|
.deleteFrom('oauth_link_token')
|
||||||
|
|||||||
@@ -762,7 +762,6 @@ describe(AuthService.name, () => {
|
|||||||
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled);
|
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled);
|
||||||
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile, sid: 'idp-sid-789' });
|
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile, sid: 'idp-sid-789' });
|
||||||
mocks.user.getByEmail.mockResolvedValue(user);
|
mocks.user.getByEmail.mockResolvedValue(user);
|
||||||
mocks.oauthLinkToken.deleteByEmail.mockResolvedValue();
|
|
||||||
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@@ -775,7 +774,6 @@ describe(AuthService.name, () => {
|
|||||||
|
|
||||||
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1);
|
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1);
|
||||||
expect(mocks.user.update).not.toHaveBeenCalled();
|
expect(mocks.user.update).not.toHaveBeenCalled();
|
||||||
expect(mocks.oauthLinkToken.deleteByEmail).toHaveBeenCalledTimes(1);
|
|
||||||
expect(mocks.oauthLinkToken.create).toHaveBeenCalledWith(
|
expect(mocks.oauthLinkToken.create).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ oauthSub: profile.sub, oauthSid: 'idp-sid-789' }),
|
expect.objectContaining({ oauthSub: profile.sub, oauthSid: 'idp-sid-789' }),
|
||||||
);
|
);
|
||||||
@@ -788,7 +786,6 @@ describe(AuthService.name, () => {
|
|||||||
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled);
|
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled);
|
||||||
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile });
|
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile });
|
||||||
mocks.user.getByEmail.mockResolvedValue(user);
|
mocks.user.getByEmail.mockResolvedValue(user);
|
||||||
mocks.oauthLinkToken.deleteByEmail.mockResolvedValue();
|
|
||||||
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@@ -810,7 +807,6 @@ describe(AuthService.name, () => {
|
|||||||
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile: OAuthProfileFactory.create() });
|
mocks.oauth.getProfileAndOAuthSid.mockResolvedValue({ profile: OAuthProfileFactory.create() });
|
||||||
mocks.user.getByEmail.mockResolvedValueOnce(user);
|
mocks.user.getByEmail.mockResolvedValueOnce(user);
|
||||||
mocks.user.getAdmin.mockResolvedValue(UserFactory.create({ isAdmin: true }));
|
mocks.user.getAdmin.mockResolvedValue(UserFactory.create({ isAdmin: true }));
|
||||||
mocks.oauthLinkToken.deleteByEmail.mockResolvedValue();
|
|
||||||
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
mocks.oauthLinkToken.create.mockResolvedValue({} as any);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
|
|||||||
@@ -350,7 +350,6 @@ export class AuthService extends BaseService {
|
|||||||
if (!user && normalizedEmail) {
|
if (!user && normalizedEmail) {
|
||||||
const emailUser = await this.userRepository.getByEmail(normalizedEmail);
|
const emailUser = await this.userRepository.getByEmail(normalizedEmail);
|
||||||
if (emailUser) {
|
if (emailUser) {
|
||||||
await this.oauthLinkTokenRepository.deleteByEmail(emailUser.email);
|
|
||||||
const plainToken = this.cryptoRepository.randomBytesAsText(32);
|
const plainToken = this.cryptoRepository.randomBytesAsText(32);
|
||||||
const hashedToken = this.cryptoRepository.hashSha256(plainToken);
|
const hashedToken = this.cryptoRepository.hashSha256(plainToken);
|
||||||
await this.oauthLinkTokenRepository.create({
|
await this.oauthLinkTokenRepository.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user