Add link to register in login form
authorChocobozzz <me@florianbigard.com>
Wed, 28 Mar 2018 16:22:59 +0000 (18:22 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 28 Mar 2018 16:22:59 +0000 (18:22 +0200)
client/src/app/login/login.component.html
client/src/app/login/login.component.scss
client/src/app/login/login.component.ts
client/src/app/shared/misc/help.component.html

index 660a082806c65eb9cbc892aa634bb4b05ccbdaed..b7fd25d27dc32cc039bd0d76c2d8530304c74633 100644 (file)
@@ -7,11 +7,26 @@
 
   <form role="form" (ngSubmit)="login()" [formGroup]="form">
     <div class="form-group">
-      <label for="username">User</label>
-      <input
-        type="text" id="username" placeholder="Username or email address" required
-        formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
-      >
+      <div>
+        <label for="username">User</label>
+        <input
+          type="text" id="username" placeholder="Username or email address" required tabindex="1"
+          formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
+        >
+        <a *ngIf="signupAllowed === true" routerLink="/signup" class="create-an-account">
+          or create an account
+        </a>
+
+        <a *ngIf="signupAllowed === false" href="https://joinpeertube.org/en/#getting-started" target="_blank" class="create-an-account">
+          or create an account on another instance
+        </a>
+
+        <my-help
+          *ngIf="signupAllowed === false" helpType="custom"
+          customHtml="User registration is not allowed on this instance, but you can register on many others!"
+        ></my-help>
+      </div>
+
       <div *ngIf="formErrors.username" class="form-error">
         {{ formErrors.username }}
       </div>
@@ -21,7 +36,7 @@
       <label for="password">Password</label>
       <div>
         <input
-          type="password" name="password" id="password" placeholder="Password" required
+          type="password" name="password" id="password" placeholder="Password" required tabindex="2"
           formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
         >
         <div class="forgot-password-button" (click)="openForgotPasswordModal()">I forgot my password</div>
index 2cf6991cef2ba38b791facfde84d01f66ff4ce7f..4a37ee961b4e3ac92a0edcb23f75088f9cb85c3b 100644 (file)
@@ -1,9 +1,15 @@
 @import '_variables';
 @import '_mixins';
 
+label {
+  display: block;
+}
+
 input:not([type=submit]) {
   @include peertube-input-text(340px);
-  display: block;
+  display: inline-block;
+  margin-right: 5px;
+
 }
 
 input[type=submit] {
@@ -11,12 +17,13 @@ input[type=submit] {
   @include orange-button;
 }
 
-input[type=password] {
-  display: inline-block;
-  margin-right: 5px;
-}
-
 .forgot-password-button {
   display: inline-block;
   cursor: pointer;
 }
+
+.create-an-account {
+  @include disable-default-a-behaviour;
+
+  color: #000;
+}
index 22e8c77dd44f4817c6367e5937c80732d6d882ac..f7b49ec459acd074da638346b09a4248a274f700 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
 import { FormBuilder, FormGroup, Validators } from '@angular/forms'
 import { Router } from '@angular/router'
+import { RedirectService, ServerService } from '@app/core'
 import { UserService } from '@app/shared'
 import { NotificationsService } from 'angular2-notifications'
 import { ModalDirective } from 'ngx-bootstrap/modal'
@@ -34,16 +35,20 @@ export class LoginComponent extends FormReactive implements OnInit {
   }
   forgotPasswordEmail = ''
 
-  constructor (
-    private authService: AuthService,
-    private userService: UserService,
-    private notificationsService: NotificationsService,
-    private formBuilder: FormBuilder,
-    private router: Router
-  ) {
+  constructor (private authService: AuthService,
+               private userService: UserService,
+               private serverService: ServerService,
+               private redirectService: RedirectService,
+               private notificationsService: NotificationsService,
+               private formBuilder: FormBuilder,
+               private router: Router) {
     super()
   }
 
+  get signupAllowed () {
+    return this.serverService.getConfig().signup.allowed === true
+  }
+
   buildForm () {
     this.form = this.formBuilder.group({
       username: [ '', Validators.required ],
@@ -62,11 +67,12 @@ export class LoginComponent extends FormReactive implements OnInit {
 
     const { username, password } = this.form.value
 
-    this.authService.login(username, password).subscribe(
-      () => this.router.navigate(['/videos/list']),
+    this.authService.login(username, password)
+      .subscribe(
+        () => this.redirectService.redirectToHomepage(),
 
-      err => this.error = err.message
-    )
+        err => this.error = err.message
+      )
   }
 
   askResetPassword () {
index bacbe9cdbb5950941740e164737f01ce4f7304f6..e37d93b621c5a98883ee58c70d79e3e4916a3fd4 100644 (file)
@@ -12,7 +12,7 @@
   </ng-template>
 </ng-template>
 
-<button
+<span
   class="help-tooltip-button" containerClass="help-tooltip" title="Click to get help"
   #tooltipDirective="bs-tooltip" [tooltip]="tooltipTemplate" triggers="click"
-></button>
+></span>