Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b084d7

Browse files
committed
Add link to register in login form
1 parent 5afdd0a commit 2b084d7

File tree

4 files changed

+53
-25
lines changed

4 files changed

+53
-25
lines changed

client/src/app/login/login.component.html

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,26 @@
77

88
<form role="form" (ngSubmit)="login()" [formGroup]="form">
99
<div class="form-group">
10-
<label for="username">User</label>
11-
<input
12-
type="text" id="username" placeholder="Username or email address" required
13-
formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
14-
>
10+
<div>
11+
<label for="username">User</label>
12+
<input
13+
type="text" id="username" placeholder="Username or email address" required tabindex="1"
14+
formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
15+
>
16+
<a *ngIf="signupAllowed === true" routerLink="/signup" class="create-an-account">
17+
or create an account
18+
</a>
19+
20+
<a *ngIf="signupAllowed === false" href="https://joinpeertube.org/en/#getting-started" target="_blank" class="create-an-account">
21+
or create an account on another instance
22+
</a>
23+
24+
<my-help
25+
*ngIf="signupAllowed === false" helpType="custom"
26+
customHtml="User registration is not allowed on this instance, but you can register on many others!"
27+
></my-help>
28+
</div>
29+
1530
<div *ngIf="formErrors.username" class="form-error">
1631
{{ formErrors.username }}
1732
</div>
@@ -21,7 +36,7 @@
2136
<label for="password">Password</label>
2237
<div>
2338
<input
24-
type="password" name="password" id="password" placeholder="Password" required
39+
type="password" name="password" id="password" placeholder="Password" required tabindex="2"
2540
formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
2641
>
2742
<div class="forgot-password-button" (click)="openForgotPasswordModal()">I forgot my password</div>
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
@import '_variables';
22
@import '_mixins';
33

4+
label {
5+
display: block;
6+
}
7+
48
input:not([type=submit]) {
59
@include peertube-input-text(340px);
6-
display: block;
10+
display: inline-block;
11+
margin-right: 5px;
12+
713
}
814

915
input[type=submit] {
1016
@include peertube-button;
1117
@include orange-button;
1218
}
1319

14-
input[type=password] {
15-
display: inline-block;
16-
margin-right: 5px;
17-
}
18-
1920
.forgot-password-button {
2021
display: inline-block;
2122
cursor: pointer;
2223
}
24+
25+
.create-an-account {
26+
@include disable-default-a-behaviour;
27+
28+
color: #000;
29+
}

client/src/app/login/login.component.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
22
import { FormBuilder, FormGroup, Validators } from '@angular/forms'
33
import { Router } from '@angular/router'
4+
import { RedirectService, ServerService } from '@app/core'
45
import { UserService } from '@app/shared'
56
import { NotificationsService } from 'angular2-notifications'
67
import { ModalDirective } from 'ngx-bootstrap/modal'
@@ -34,16 +35,20 @@ export class LoginComponent extends FormReactive implements OnInit {
3435
}
3536
forgotPasswordEmail = ''
3637

37-
constructor (
38-
private authService: AuthService,
39-
private userService: UserService,
40-
private notificationsService: NotificationsService,
41-
private formBuilder: FormBuilder,
42-
private router: Router
43-
) {
38+
constructor (private authService: AuthService,
39+
private userService: UserService,
40+
private serverService: ServerService,
41+
private redirectService: RedirectService,
42+
private notificationsService: NotificationsService,
43+
private formBuilder: FormBuilder,
44+
private router: Router) {
4445
super()
4546
}
4647

48+
get signupAllowed () {
49+
return this.serverService.getConfig().signup.allowed === true
50+
}
51+
4752
buildForm () {
4853
this.form = this.formBuilder.group({
4954
username: [ '', Validators.required ],
@@ -62,11 +67,12 @@ export class LoginComponent extends FormReactive implements OnInit {
6267

6368
const { username, password } = this.form.value
6469

65-
this.authService.login(username, password).subscribe(
66-
() => this.router.navigate(['/videos/list']),
70+
this.authService.login(username, password)
71+
.subscribe(
72+
() => this.redirectService.redirectToHomepage(),
6773

68-
err => this.error = err.message
69-
)
74+
err => this.error = err.message
75+
)
7076
}
7177

7278
askResetPassword () {

client/src/app/shared/misc/help.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ng-template>
1313
</ng-template>
1414

15-
<button
15+
<span
1616
class="help-tooltip-button" containerClass="help-tooltip" title="Click to get help"
1717
#tooltipDirective="bs-tooltip" [tooltip]="tooltipTemplate" triggers="click"
18-
></button>
18+
></span>

0 commit comments

Comments
 (0)