From b247a132709eb212fef4f77c4912dc0ec108f36b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 May 2019 14:39:49 +0200 Subject: [PATCH] Add success icon on registration --- .../+register}/custom-stepper.component.html | 0 .../+register}/custom-stepper.component.scss | 0 .../+register}/custom-stepper.component.ts | 0 .../+register/register-routing.module.ts} | 17 +++++----- .../register-step-channel.component.html} | 0 .../register-step-channel.component.ts} | 10 +++--- .../register-step-user.component.html} | 0 .../register-step-user.component.ts} | 10 +++--- .../+register/register.component.html} | 8 ++--- .../+register/register.component.scss} | 0 .../+register/register.component.ts} | 12 +++---- .../app/+signup/+register/register.module.ts | 33 +++++++++++++++++++ ...rify-account-ask-send-email.component.html | 0 ...rify-account-ask-send-email.component.scss | 0 ...verify-account-ask-send-email.component.ts | 0 .../verify-account-email.component.html | 6 ++-- .../verify-account-email.component.ts | 3 -- .../verify-account-routing.module.ts | 8 ++--- .../+verify-account/verify-account.module.ts | 25 ++++++++++++++ .../+signup/shared/signup-shared.module.ts | 21 ++++++++++++ .../shared/signup-success.component.html} | 10 +++++- .../shared/signup-success.component.scss} | 10 +++--- .../shared/signup-success.component.ts | 10 ++++++ client/src/app/+verify-account/index.ts | 2 -- .../+verify-account/verify-account.module.ts | 27 --------------- client/src/app/app-routing.module.ts | 6 +++- client/src/app/app.module.ts | 2 -- client/src/app/core/core.module.ts | 3 ++ .../src/app/core/routing/redirect.service.ts | 9 ++++- .../core/routing/unlogged-guard.service.ts | 25 ++++++++++++++ client/src/app/signup/index.ts | 3 -- client/src/app/signup/signup.module.ts | 33 ------------------- client/src/app/signup/success.component.ts | 10 ------ 33 files changed, 178 insertions(+), 125 deletions(-) rename client/src/app/{signup => +signup/+register}/custom-stepper.component.html (100%) rename client/src/app/{signup => +signup/+register}/custom-stepper.component.scss (100%) rename client/src/app/{signup => +signup/+register}/custom-stepper.component.ts (100%) rename client/src/app/{signup/signup-routing.module.ts => +signup/+register/register-routing.module.ts} (50%) rename client/src/app/{signup/signup-step-channel.component.html => +signup/+register/register-step-channel.component.html} (100%) rename client/src/app/{signup/signup-step-channel.component.ts => +signup/+register/register-step-channel.component.ts} (76%) rename client/src/app/{signup/signup-step-user.component.html => +signup/+register/register-step-user.component.html} (100%) rename client/src/app/{signup/signup-step-user.component.ts => +signup/+register/register-step-user.component.ts} (76%) rename client/src/app/{signup/signup.component.html => +signup/+register/register.component.html} (77%) rename client/src/app/{signup/signup.component.scss => +signup/+register/register.component.scss} (100%) rename client/src/app/{signup/signup.component.ts => +signup/+register/register.component.ts} (89%) create mode 100644 client/src/app/+signup/+register/register.module.ts rename client/src/app/{ => +signup}/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.html (100%) rename client/src/app/{ => +signup}/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.scss (100%) rename client/src/app/{ => +signup}/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts (100%) rename client/src/app/{ => +signup}/+verify-account/verify-account-email/verify-account-email.component.html (69%) rename client/src/app/{ => +signup}/+verify-account/verify-account-email/verify-account-email.component.ts (93%) rename client/src/app/{ => +signup}/+verify-account/verify-account-routing.module.ts (75%) create mode 100644 client/src/app/+signup/+verify-account/verify-account.module.ts create mode 100644 client/src/app/+signup/shared/signup-shared.module.ts rename client/src/app/{signup/success.component.html => +signup/shared/signup-success.component.html} (58%) rename client/src/app/{signup/success.component.scss => +signup/shared/signup-success.component.scss} (92%) create mode 100644 client/src/app/+signup/shared/signup-success.component.ts delete mode 100644 client/src/app/+verify-account/index.ts delete mode 100644 client/src/app/+verify-account/verify-account.module.ts create mode 100644 client/src/app/core/routing/unlogged-guard.service.ts delete mode 100644 client/src/app/signup/index.ts delete mode 100644 client/src/app/signup/signup.module.ts delete mode 100644 client/src/app/signup/success.component.ts diff --git a/client/src/app/signup/custom-stepper.component.html b/client/src/app/+signup/+register/custom-stepper.component.html similarity index 100% rename from client/src/app/signup/custom-stepper.component.html rename to client/src/app/+signup/+register/custom-stepper.component.html diff --git a/client/src/app/signup/custom-stepper.component.scss b/client/src/app/+signup/+register/custom-stepper.component.scss similarity index 100% rename from client/src/app/signup/custom-stepper.component.scss rename to client/src/app/+signup/+register/custom-stepper.component.scss diff --git a/client/src/app/signup/custom-stepper.component.ts b/client/src/app/+signup/+register/custom-stepper.component.ts similarity index 100% rename from client/src/app/signup/custom-stepper.component.ts rename to client/src/app/+signup/+register/custom-stepper.component.ts diff --git a/client/src/app/signup/signup-routing.module.ts b/client/src/app/+signup/+register/register-routing.module.ts similarity index 50% rename from client/src/app/signup/signup-routing.module.ts rename to client/src/app/+signup/+register/register-routing.module.ts index 820d16d4d..e3a5001dc 100644 --- a/client/src/app/signup/signup-routing.module.ts +++ b/client/src/app/+signup/+register/register-routing.module.ts @@ -1,17 +1,18 @@ import { NgModule } from '@angular/core' import { RouterModule, Routes } from '@angular/router' import { MetaGuard } from '@ngx-meta/core' -import { SignupComponent } from './signup.component' +import { RegisterComponent } from './register.component' import { ServerConfigResolver } from '@app/core/routing/server-config-resolver.service' +import { UnloggedGuard } from '@app/core/routing/unlogged-guard.service' -const signupRoutes: Routes = [ +const registerRoutes: Routes = [ { - path: 'signup', - component: SignupComponent, - canActivate: [ MetaGuard ], + path: '', + component: RegisterComponent, + canActivate: [ MetaGuard, UnloggedGuard ], data: { meta: { - title: 'Signup' + title: 'Register' } }, resolve: { @@ -21,7 +22,7 @@ const signupRoutes: Routes = [ ] @NgModule({ - imports: [ RouterModule.forChild(signupRoutes) ], + imports: [ RouterModule.forChild(registerRoutes) ], exports: [ RouterModule ] }) -export class SignupRoutingModule {} +export class RegisterRoutingModule {} diff --git a/client/src/app/signup/signup-step-channel.component.html b/client/src/app/+signup/+register/register-step-channel.component.html similarity index 100% rename from client/src/app/signup/signup-step-channel.component.html rename to client/src/app/+signup/+register/register-step-channel.component.html diff --git a/client/src/app/signup/signup-step-channel.component.ts b/client/src/app/+signup/+register/register-step-channel.component.ts similarity index 76% rename from client/src/app/signup/signup-step-channel.component.ts rename to client/src/app/+signup/+register/register-step-channel.component.ts index a49b7f36f..9e13f75b3 100644 --- a/client/src/app/signup/signup-step-channel.component.ts +++ b/client/src/app/+signup/+register/register-step-channel.component.ts @@ -1,15 +1,15 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { AuthService } from '@app/core' -import { FormReactive, VideoChannelValidatorsService } from '../shared' +import { FormReactive, VideoChannelValidatorsService } from '@app/shared' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { FormGroup } from '@angular/forms' @Component({ - selector: 'my-signup-step-channel', - templateUrl: './signup-step-channel.component.html', - styleUrls: [ './signup.component.scss' ] + selector: 'my-register-step-channel', + templateUrl: './register-step-channel.component.html', + styleUrls: [ './register.component.scss' ] }) -export class SignupStepChannelComponent extends FormReactive implements OnInit { +export class RegisterStepChannelComponent extends FormReactive implements OnInit { @Input() username: string @Output() formBuilt = new EventEmitter() diff --git a/client/src/app/signup/signup-step-user.component.html b/client/src/app/+signup/+register/register-step-user.component.html similarity index 100% rename from client/src/app/signup/signup-step-user.component.html rename to client/src/app/+signup/+register/register-step-user.component.html diff --git a/client/src/app/signup/signup-step-user.component.ts b/client/src/app/+signup/+register/register-step-user.component.ts similarity index 76% rename from client/src/app/signup/signup-step-user.component.ts rename to client/src/app/+signup/+register/register-step-user.component.ts index 54855d8a7..3825ae371 100644 --- a/client/src/app/signup/signup-step-user.component.ts +++ b/client/src/app/+signup/+register/register-step-user.component.ts @@ -1,15 +1,15 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core' import { AuthService } from '@app/core' -import { FormReactive, UserValidatorsService } from '../shared' +import { FormReactive, UserValidatorsService } from '@app/shared' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { FormGroup } from '@angular/forms' @Component({ - selector: 'my-signup-step-user', - templateUrl: './signup-step-user.component.html', - styleUrls: [ './signup.component.scss' ] + selector: 'my-register-step-user', + templateUrl: './register-step-user.component.html', + styleUrls: [ './register.component.scss' ] }) -export class SignupStepUserComponent extends FormReactive implements OnInit { +export class RegisterStepUserComponent extends FormReactive implements OnInit { @Output() formBuilt = new EventEmitter() constructor ( diff --git a/client/src/app/signup/signup.component.html b/client/src/app/+signup/+register/register.component.html similarity index 77% rename from client/src/app/signup/signup.component.html rename to client/src/app/+signup/+register/register.component.html index ae3a595e9..24def68c1 100644 --- a/client/src/app/signup/signup.component.html +++ b/client/src/app/+signup/+register/register.component.html @@ -4,22 +4,20 @@ Create an account - - +
{{ info }}
-
{{ success }}
- + - +
-
- Your email has been verified and you may now login. Redirecting... -
+ + +
An error occurred. diff --git a/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts b/client/src/app/+signup/+verify-account/verify-account-email/verify-account-email.component.ts similarity index 93% rename from client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts rename to client/src/app/+signup/+verify-account/verify-account-email/verify-account-email.component.ts index f9ecf664b..3fb2d1cd8 100644 --- a/client/src/app/+verify-account/verify-account-email/verify-account-email.component.ts +++ b/client/src/app/+signup/+verify-account/verify-account-email/verify-account-email.component.ts @@ -40,9 +40,6 @@ export class VerifyAccountEmailComponent implements OnInit { .subscribe( () => { this.success = true - setTimeout(() => { - this.router.navigate([ '/login' ]) - }, 2000) }, err => { diff --git a/client/src/app/+verify-account/verify-account-routing.module.ts b/client/src/app/+signup/+verify-account/verify-account-routing.module.ts similarity index 75% rename from client/src/app/+verify-account/verify-account-routing.module.ts rename to client/src/app/+signup/+verify-account/verify-account-routing.module.ts index a038f0336..16d5fe0d0 100644 --- a/client/src/app/+verify-account/verify-account-routing.module.ts +++ b/client/src/app/+signup/+verify-account/verify-account-routing.module.ts @@ -1,12 +1,8 @@ import { NgModule } from '@angular/core' import { RouterModule, Routes } from '@angular/router' - import { MetaGuard } from '@ngx-meta/core' - -import { VerifyAccountEmailComponent } from '@app/+verify-account/verify-account-email/verify-account-email.component' -import { - VerifyAccountAskSendEmailComponent -} from '@app/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component' +import { VerifyAccountEmailComponent } from './verify-account-email/verify-account-email.component' +import { VerifyAccountAskSendEmailComponent } from './verify-account-ask-send-email/verify-account-ask-send-email.component' const verifyAccountRoutes: Routes = [ { diff --git a/client/src/app/+signup/+verify-account/verify-account.module.ts b/client/src/app/+signup/+verify-account/verify-account.module.ts new file mode 100644 index 000000000..9fe14e81e --- /dev/null +++ b/client/src/app/+signup/+verify-account/verify-account.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core' +import { VerifyAccountRoutingModule } from './verify-account-routing.module' +import { VerifyAccountEmailComponent } from './verify-account-email/verify-account-email.component' +import { VerifyAccountAskSendEmailComponent } from './verify-account-ask-send-email/verify-account-ask-send-email.component' +import { SharedModule } from '@app/shared' +import { SignupSharedModule } from '@app/+signup/shared/signup-shared.module' + +@NgModule({ + imports: [ + VerifyAccountRoutingModule, + SharedModule, + SignupSharedModule + ], + + declarations: [ + VerifyAccountEmailComponent, + VerifyAccountAskSendEmailComponent + ], + + exports: [], + + providers: [] +}) +export class VerifyAccountModule { +} diff --git a/client/src/app/+signup/shared/signup-shared.module.ts b/client/src/app/+signup/shared/signup-shared.module.ts new file mode 100644 index 000000000..cd21fdef3 --- /dev/null +++ b/client/src/app/+signup/shared/signup-shared.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core' +import { SignupSuccessComponent } from '../shared/signup-success.component' +import { SharedModule } from '@app/shared' + +@NgModule({ + imports: [ + SharedModule + ], + + declarations: [ + SignupSuccessComponent + ], + + exports: [ + SignupSuccessComponent + ], + + providers: [ + ] +}) +export class SignupSharedModule { } diff --git a/client/src/app/signup/success.component.html b/client/src/app/+signup/shared/signup-success.component.html similarity index 58% rename from client/src/app/signup/success.component.html rename to client/src/app/+signup/shared/signup-success.component.html index 68eb72b61..e35f858c6 100644 --- a/client/src/app/signup/success.component.html +++ b/client/src/app/+signup/shared/signup-success.component.html @@ -5,4 +5,12 @@ -

Welcome on PeerTube!

+

Welcome on PeerTube!

+ +
+

{{ message }}

+ +

+ If you need help to use PeerTube, you can take a look to the documentation. +

+
diff --git a/client/src/app/signup/success.component.scss b/client/src/app/+signup/shared/signup-success.component.scss similarity index 92% rename from client/src/app/signup/success.component.scss rename to client/src/app/+signup/shared/signup-success.component.scss index 7c66e08cf..fbc27c8bc 100644 --- a/client/src/app/signup/success.component.scss +++ b/client/src/app/+signup/shared/signup-success.component.scss @@ -26,14 +26,16 @@ svg { } } -p { +.bottom-message { text-align: center; margin: 20px 0 60px; font-size: 1.25em; + color: #73AF55; +} - &.success { - color: #73AF55; - } +.alert { + font-size: 15px; + text-align: center; } diff --git a/client/src/app/+signup/shared/signup-success.component.ts b/client/src/app/+signup/shared/signup-success.component.ts new file mode 100644 index 000000000..19fb5922a --- /dev/null +++ b/client/src/app/+signup/shared/signup-success.component.ts @@ -0,0 +1,10 @@ +import { Component, Input } from '@angular/core' + +@Component({ + selector: 'my-signup-success', + templateUrl: './signup-success.component.html', + styleUrls: [ './signup-success.component.scss' ] +}) +export class SignupSuccessComponent { + @Input() message: string +} diff --git a/client/src/app/+verify-account/index.ts b/client/src/app/+verify-account/index.ts deleted file mode 100644 index 733f5ba77..000000000 --- a/client/src/app/+verify-account/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from '@app/+verify-account/verify-account-routing.module' -export * from '@app/+verify-account/verify-account.module' diff --git a/client/src/app/+verify-account/verify-account.module.ts b/client/src/app/+verify-account/verify-account.module.ts deleted file mode 100644 index 9092c6b4f..000000000 --- a/client/src/app/+verify-account/verify-account.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule } from '@angular/core' - -import { VerifyAccountRoutingModule } from '@app/+verify-account/verify-account-routing.module' -import { VerifyAccountEmailComponent } from '@app/+verify-account/verify-account-email/verify-account-email.component' -import { - VerifyAccountAskSendEmailComponent -} from '@app/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component' -import { SharedModule } from '@app/shared' - -@NgModule({ - imports: [ - VerifyAccountRoutingModule, - SharedModule - ], - - declarations: [ - VerifyAccountEmailComponent, - VerifyAccountAskSendEmailComponent - ], - - exports: [ - ], - - providers: [ - ] -}) -export class VerifyAccountModule { } diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index db8888dba..7ca51f226 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -16,7 +16,7 @@ const routes: Routes = [ }, { path: 'verify-account', - loadChildren: './+verify-account/verify-account.module#VerifyAccountModule' + loadChildren: './+signup/+verify-account/verify-account.module#VerifyAccountModule' }, { path: 'accounts', @@ -30,6 +30,10 @@ const routes: Routes = [ path: 'about', loadChildren: './+about/about.module#AboutModule' }, + { + path: 'signup', + loadChildren: './+signup/+register/register.module#RegisterModule' + }, { path: '', component: AppComponent // Avoid 404, app component will redirect dynamically diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 0bbc2e08b..1e2936a37 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -14,7 +14,6 @@ import { HeaderComponent } from './header' import { LoginModule } from './login' import { AvatarNotificationComponent, LanguageChooserComponent, MenuComponent } from './menu' import { SharedModule } from './shared' -import { SignupModule } from './signup' import { VideosModule } from './videos' import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n' import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' @@ -53,7 +52,6 @@ export function metaFactory (serverService: ServerService): MetaLoader { CoreModule, LoginModule, ResetPasswordModule, - SignupModule, SearchModule, SharedModule, VideosModule, diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index d3e72afb4..06fa8fcf1 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts @@ -20,6 +20,7 @@ import { Notifier } from './notification' import { MessageService } from 'primeng/api' import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' import { ServerConfigResolver } from './routing/server-config-resolver.service' +import { UnloggedGuard } from '@app/core/routing/unlogged-guard.service' @NgModule({ imports: [ @@ -58,6 +59,8 @@ import { ServerConfigResolver } from './routing/server-config-resolver.service' ThemeService, LoginGuard, UserRightGuard, + UnloggedGuard, + RedirectService, Notifier, MessageService, diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index e1db4097b..571822b76 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts @@ -42,7 +42,14 @@ export class RedirectService { } redirectToPreviousRoute () { - if (this.previousUrl) return this.router.navigateByUrl(this.previousUrl) + const exceptions = [ + '/verify-account' + ] + + if (this.previousUrl) { + const isException = exceptions.find(e => this.previousUrl.startsWith(e)) + if (!isException) return this.router.navigateByUrl(this.previousUrl) + } return this.redirectToHomepage() } diff --git a/client/src/app/core/routing/unlogged-guard.service.ts b/client/src/app/core/routing/unlogged-guard.service.ts new file mode 100644 index 000000000..3132a1a77 --- /dev/null +++ b/client/src/app/core/routing/unlogged-guard.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core' +import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' +import { AuthService } from '../auth/auth.service' +import { RedirectService } from './redirect.service' + +@Injectable() +export class UnloggedGuard implements CanActivate, CanActivateChild { + + constructor ( + private router: Router, + private auth: AuthService, + private redirectService: RedirectService + ) {} + + canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + if (this.auth.isLoggedIn() === false) return true + + this.redirectService.redirectToHomepage() + return false + } + + canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + return this.canActivate(route, state) + } +} diff --git a/client/src/app/signup/index.ts b/client/src/app/signup/index.ts deleted file mode 100644 index b0aca9723..000000000 --- a/client/src/app/signup/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './signup-routing.module' -export * from './signup.component' -export * from './signup.module' diff --git a/client/src/app/signup/signup.module.ts b/client/src/app/signup/signup.module.ts deleted file mode 100644 index fccaf7ce1..000000000 --- a/client/src/app/signup/signup.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { NgModule } from '@angular/core' -import { SignupRoutingModule } from './signup-routing.module' -import { SignupComponent } from './signup.component' -import { SharedModule } from '../shared' -import { CdkStepperModule } from '@angular/cdk/stepper' -import { SignupStepChannelComponent } from '@app/signup/signup-step-channel.component' -import { SignupStepUserComponent } from '@app/signup/signup-step-user.component' -import { CustomStepperComponent } from '@app/signup/custom-stepper.component' -import { SuccessComponent } from '@app/signup/success.component' - -@NgModule({ - imports: [ - SignupRoutingModule, - SharedModule, - CdkStepperModule - ], - - declarations: [ - SignupComponent, - CustomStepperComponent, - SuccessComponent, - SignupStepChannelComponent, - SignupStepUserComponent - ], - - exports: [ - SignupComponent - ], - - providers: [ - ] -}) -export class SignupModule { } diff --git a/client/src/app/signup/success.component.ts b/client/src/app/signup/success.component.ts deleted file mode 100644 index 2674e1e30..000000000 --- a/client/src/app/signup/success.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core' - -@Component({ - selector: 'my-success', - templateUrl: './success.component.html', - styleUrls: [ './success.component.scss' ] -}) -export class SuccessComponent { - -} -- 2.41.0