import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { getExternalAuthHref } from '@shared/core-utils'
-import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
+import { RegisteredExternalAuthConfig, ServerConfig, ServerErrorCode } from '@shared/models'
@Component({
selector: 'my-login',
}
private handleError (err: any) {
+ console.log(err)
+
if (this.authService.isOTPMissingError(err)) {
this.otpStep = true
return
}
- if (err.message.indexOf('credentials are invalid') !== -1) this.error = $localize`Incorrect username or password.`
- else if (err.message.indexOf('blocked') !== -1) this.error = $localize`Your account is blocked.`
- else this.error = err.message
+ if (err.message.includes('credentials are invalid')) {
+ this.error = $localize`Incorrect username or password.`
+ return
+ }
+
+ if (err.message.includes('blocked')) {
+ this.error = $localize`Your account is blocked.`
+ return
+ }
+
+ if (err.body?.code === ServerErrorCode.ACCOUNT_WAITING_FOR_APPROVAL) {
+ this.error = $localize`This account is awaiting approval by moderators.`
+ return
+ }
+
+ if (err.body?.code === ServerErrorCode.ACCOUNT_APPROVAL_REJECTED) {
+ this.error = $localize`Registration approval has been rejected for this account.`
+ return
+ }
+
+ this.error = err.message
}
}