Add link to register in login form

pull/429/head
Chocobozzz 2018-03-28 18:22:59 +02:00
parent 5afdd0a52f
commit 2b084d7048
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 53 additions and 25 deletions

View File

@ -7,11 +7,26 @@
<form role="form" (ngSubmit)="login()" [formGroup]="form">
<div class="form-group">
<div>
<label for="username">User</label>
<input
type="text" id="username" placeholder="Username or email address" required
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>

View 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;
}

View 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,
constructor (private authService: AuthService,
private userService: UserService,
private serverService: ServerService,
private redirectService: RedirectService,
private notificationsService: NotificationsService,
private formBuilder: FormBuilder,
private router: Router
) {
private router: Router) {
super()
}
get signupAllowed () {
return this.serverService.getConfig().signup.allowed === true
}
buildForm () {
this.form = this.formBuilder.group({
username: [ '', Validators.required ],
@ -62,8 +67,9 @@ 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
)

View 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>