From 1942f11d5ee6926ad93dc1b79fae18325ba5de18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:49:20 +0200 Subject: Lazy load all routes --- client/src/app/login/index.ts | 3 - client/src/app/login/login-routing.module.ts | 27 ----- client/src/app/login/login.component.html | 114 --------------------- client/src/app/login/login.component.scss | 66 ------------ client/src/app/login/login.component.ts | 147 --------------------------- client/src/app/login/login.module.ts | 28 ----- 6 files changed, 385 deletions(-) delete mode 100644 client/src/app/login/index.ts delete mode 100644 client/src/app/login/login-routing.module.ts delete mode 100644 client/src/app/login/login.component.html delete mode 100644 client/src/app/login/login.component.scss delete mode 100644 client/src/app/login/login.component.ts delete mode 100644 client/src/app/login/login.module.ts (limited to 'client/src/app/login') diff --git a/client/src/app/login/index.ts b/client/src/app/login/index.ts deleted file mode 100644 index f1301d8b5..000000000 --- a/client/src/app/login/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './login-routing.module' -export * from './login.component' -export * from './login.module' diff --git a/client/src/app/login/login-routing.module.ts b/client/src/app/login/login-routing.module.ts deleted file mode 100644 index 22f59b4d9..000000000 --- a/client/src/app/login/login-routing.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule } from '@angular/core' -import { RouterModule, Routes } from '@angular/router' -import { MetaGuard } from '@ngx-meta/core' -import { LoginComponent } from './login.component' -import { ServerConfigResolver } from '@app/core/routing/server-config-resolver.service' - -const loginRoutes: Routes = [ - { - path: 'login', - component: LoginComponent, - canActivate: [ MetaGuard ], - data: { - meta: { - title: 'Login' - } - }, - resolve: { - serverConfig: ServerConfigResolver - } - } -] - -@NgModule({ - imports: [ RouterModule.forChild(loginRoutes) ], - exports: [ RouterModule ] -}) -export class LoginRoutingModule {} diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html deleted file mode 100644 index 599b203ae..000000000 --- a/client/src/app/login/login.component.html +++ /dev/null @@ -1,114 +0,0 @@ -
-
- Login -
- -
- Sorry but there was an issue with the external login process. Please contact an administrator. -
- - - - - - - - - -
- - - - - - - - diff --git a/client/src/app/login/login.component.scss b/client/src/app/login/login.component.scss deleted file mode 100644 index fde6cc15e..000000000 --- a/client/src/app/login/login.component.scss +++ /dev/null @@ -1,66 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -label { - display: block; -} - -input:not([type=submit]) { - @include peertube-input-text(340px); - display: inline-block; - margin-right: 5px; - -} - -input[type=submit] { - @include peertube-button; - @include orange-button; -} - -.create-an-account, .forgot-password-button { - color: pvar(--mainForegroundColor); - cursor: pointer; - transition: opacity cubic-bezier(0.39, 0.575, 0.565, 1); - - &:hover { - text-decoration: none !important; - opacity: .7 !important; - } -} - -.login-form-and-externals { - display: flex; - flex-wrap: wrap; - font-size: 15px; - - form { - margin: 0 50px 20px 0; - } - - .external-login-blocks { - min-width: 200px; - - .block-title { - font-weight: $font-semibold; - } - - .external-login-block { - @include disable-default-a-behaviour; - - cursor: pointer; - border: 1px solid #d1d7e0; - border-radius: 5px; - color: pvar(--mainForegroundColor); - margin: 10px 10px 0 0; - display: flex; - justify-content: center; - align-items: center; - min-height: 35px; - min-width: 100px; - - &:hover { - background-color: rgba(209, 215, 224, 0.5) - } - } - } -} diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts deleted file mode 100644 index cbc51ee21..000000000 --- a/client/src/app/login/login.component.ts +++ /dev/null @@ -1,147 +0,0 @@ -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 { HooksService } from '@app/core/plugins/hooks.service' -import { FormReactive, FormValidatorService, LoginValidatorsService } from '@app/shared/shared-forms' -import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models' - -@Component({ - selector: 'my-login', - templateUrl: './login.component.html', - styleUrls: [ './login.component.scss' ] -}) - -export class LoginComponent extends FormReactive implements OnInit, AfterViewInit { - @ViewChild('usernameInput', { static: false }) usernameInput: ElementRef - @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef - - error: string = null - forgotPasswordEmail = '' - - isAuthenticatedWithExternalAuth = false - externalAuthError = false - externalLogins: string[] = [] - - private openedForgotPasswordModal: NgbModalRef - private serverConfig: ServerConfig - - constructor ( - protected formValidatorService: FormValidatorService, - private route: ActivatedRoute, - private modalService: NgbModal, - private loginValidatorsService: LoginValidatorsService, - private authService: AuthService, - private userService: UserService, - private redirectService: RedirectService, - private notifier: Notifier, - private hooks: HooksService, - private i18n: I18n - ) { - super() - } - - get signupAllowed () { - return this.serverConfig.signup.allowed === true - } - - isEmailDisabled () { - return this.serverConfig.email.enabled === false - } - - ngOnInit () { - const snapshot = this.route.snapshot - - this.serverConfig = snapshot.data.serverConfig - - if (snapshot.queryParams.externalAuthToken) { - this.loadExternalAuthToken(snapshot.queryParams.username, snapshot.queryParams.externalAuthToken) - return - } - - if (snapshot.queryParams.externalAuthError) { - this.externalAuthError = true - return - } - - this.buildForm({ - username: this.loginValidatorsService.LOGIN_USERNAME, - password: this.loginValidatorsService.LOGIN_PASSWORD - }) - } - - ngAfterViewInit () { - if (this.usernameInput) { - this.usernameInput.nativeElement.focus() - } - - this.hooks.runAction('action:login.init', 'login') - } - - getExternalLogins () { - return this.serverConfig.plugin.registeredExternalAuths - } - - getAuthHref (auth: RegisteredExternalAuthConfig) { - return environment.apiUrl + `/plugins/${auth.name}/${auth.version}/auth/${auth.authName}` - } - - login () { - this.error = null - - const { username, password } = this.form.value - - this.authService.login(username, password) - .subscribe( - () => this.redirectService.redirectToPreviousRoute(), - - err => this.handleError(err) - ) - } - - askResetPassword () { - this.userService.askResetPassword(this.forgotPasswordEmail) - .subscribe( - () => { - const message = this.i18n( - 'An email with the reset password instructions will be sent to {{email}}. The link will expire within 1 hour.', - { email: this.forgotPasswordEmail } - ) - this.notifier.success(message) - this.hideForgotPasswordModal() - }, - - err => this.notifier.error(err.message) - ) - } - - openForgotPasswordModal () { - this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal) - } - - hideForgotPasswordModal () { - this.openedForgotPasswordModal.close() - } - - private loadExternalAuthToken (username: string, token: string) { - this.isAuthenticatedWithExternalAuth = true - - this.authService.login(username, null, token) - .subscribe( - () => this.redirectService.redirectToPreviousRoute(), - - err => { - this.handleError(err) - this.isAuthenticatedWithExternalAuth = false - } - ) - } - - private handleError (err: any) { - if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') - else if (err.message.indexOf('blocked') !== -1) this.error = this.i18n('You account is blocked.') - else this.error = err.message - } -} diff --git a/client/src/app/login/login.module.ts b/client/src/app/login/login.module.ts deleted file mode 100644 index c41902426..000000000 --- a/client/src/app/login/login.module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule } from '@angular/core' -import { SharedFormModule } from '@app/shared/shared-forms' -import { SharedGlobalIconModule } from '@app/shared/shared-icons' -import { SharedMainModule } from '@app/shared/shared-main' -import { LoginRoutingModule } from './login-routing.module' -import { LoginComponent } from './login.component' - -@NgModule({ - imports: [ - LoginRoutingModule, - - SharedMainModule, - SharedFormModule, - SharedGlobalIconModule - ], - - declarations: [ - LoginComponent - ], - - exports: [ - LoginComponent - ], - - providers: [ - ] -}) -export class LoginModule { } -- cgit v1.2.3