-import { environment } from 'src/environments/environment'
+
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { AuthService, Notifier, RedirectService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceAboutAccordionComponent } from '@app/shared/shared-instance'
import { NgbAccordion, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
+import { PluginsManager } from '@root-helpers/plugins-manager'
import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
@Component({
private redirectService: RedirectService,
private notifier: Notifier,
private hooks: HooksService
- ) {
+ ) {
super()
}
}
getAuthHref (auth: RegisteredExternalAuthConfig) {
- return environment.apiUrl + `/plugins/${auth.name}/${auth.version}/auth/${auth.authName}`
+ return PluginsManager.getExternalAuthHref(auth)
}
login () {
const { username, password } = this.form.value
this.authService.login(username, password)
- .subscribe(
- () => this.redirectService.redirectToPreviousRoute(),
+ .subscribe({
+ next: () => this.redirectService.redirectToPreviousRoute(),
- err => this.handleError(err)
- )
+ error: err => this.handleError(err)
+ })
}
askResetPassword () {
this.userService.askResetPassword(this.forgotPasswordEmail)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const message = $localize`An email with the reset password instructions will be sent to ${this.forgotPasswordEmail}.
The link will expire within 1 hour.`
this.hideForgotPasswordModal()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
openForgotPasswordModal () {
this.isAuthenticatedWithExternalAuth = true
this.authService.login(username, null, token)
- .subscribe(
- () => this.redirectService.redirectToPreviousRoute(),
-
- err => {
- this.handleError(err)
- this.isAuthenticatedWithExternalAuth = false
- }
- )
+ .subscribe({
+ next: () => this.redirectService.redirectToPreviousRoute(),
+
+ error: err => {
+ this.handleError(err)
+ this.isAuthenticatedWithExternalAuth = false
+ }
+ })
}
private handleError (err: any) {