mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat(server): remove phone number from authentication endpoints
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
import { Container, Service } from 'typedi';
|
||||
import events from '@/subscribers/events';
|
||||
import { IAuthSignedInEventPayload } from '@/interfaces';
|
||||
|
||||
@Service()
|
||||
export default class ResetLoginThrottleSubscriber {
|
||||
/**
|
||||
* Attaches events with handlers.
|
||||
* @param bus
|
||||
* @param bus
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(events.auth.login, this.resetLoginThrottleOnceSuccessLogin);
|
||||
bus.subscribe(events.auth.signIn, this.resetLoginThrottleOnceSuccessLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the login throttle once the login success.
|
||||
* @param {IAuthSignedInEventPayload} payload -
|
||||
*/
|
||||
private async resetLoginThrottleOnceSuccessLogin(payload) {
|
||||
const { emailOrPhone, password, user } = payload;
|
||||
|
||||
private async resetLoginThrottleOnceSuccessLogin(
|
||||
payload: IAuthSignedInEventPayload
|
||||
) {
|
||||
const { email, user } = payload;
|
||||
const loginThrottler = Container.get('rateLimiter.login');
|
||||
|
||||
// Reset the login throttle by the given email and phone number.
|
||||
await loginThrottler.reset(user.email);
|
||||
await loginThrottler.reset(user.phoneNumber);
|
||||
await loginThrottler.reset(emailOrPhone);
|
||||
await loginThrottler.reset(email);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ export default class AuthSendWelcomeMailSubscriber {
|
||||
* Attaches events with handlers.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(events.auth.register, this.sendWelcomeEmailOnceUserRegister);
|
||||
bus.subscribe(events.auth.signUp, this.sendWelcomeEmailOnceUserRegister);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends welcome email once the user register.
|
||||
*/
|
||||
private sendWelcomeEmailOnceUserRegister = async (payload) => {
|
||||
const { registerDTO, tenant, user } = payload;
|
||||
const { tenant, user } = payload;
|
||||
|
||||
// Send welcome mail to the user.
|
||||
await this.agenda.now('welcome-email', {
|
||||
|
||||
@@ -3,13 +3,17 @@ export default {
|
||||
* Authentication service.
|
||||
*/
|
||||
auth: {
|
||||
login: 'onLogin',
|
||||
logining: 'onLogining',
|
||||
register: 'onRegister',
|
||||
registering: 'onAuthRegistering',
|
||||
sendResetPassword: 'onSendResetPassword',
|
||||
signIn: 'onSignIn',
|
||||
signingIn: 'onSigningIn',
|
||||
|
||||
signUp: 'onSignUp',
|
||||
signingUp: 'onSigningUp',
|
||||
|
||||
sendingResetPassword: 'onSendingResetPassword',
|
||||
sendResetPassword: 'onSendResetPassword',
|
||||
|
||||
resetPassword: 'onResetPassword',
|
||||
resetingPassword: 'onResetingPassword'
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user