1
0
Fork 0

Cleanup login form

This commit is contained in:
Chocobozzz 2020-01-21 10:52:22 +01:00
parent 4ee6a8b13e
commit 21e6dc811d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 9 additions and 53 deletions

View File

@ -4,7 +4,7 @@
>
<span (click)="doSearch()" class="icon icon-search"></span>
<a class="upload-button" [routerLink]="routerLink">
<a class="upload-button" routerLink="/videos/upload">
<my-global-icon iconName="upload"></my-global-icon>
<span i18n class="upload-button-label">Upload</span>
</a>

View File

@ -2,9 +2,8 @@ import { filter, first, map, tap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router'
import { getParameterByName } from '../shared/misc/utils'
import { AuthService, ServerService, Notifier } from '@app/core'
import { AuthService, Notifier, ServerService } from '@app/core'
import { of } from 'rxjs'
import { ServerConfig } from '@shared/models'
import { I18n } from '@ngx-translate/i18n-polyfill'
@Component({
@ -17,8 +16,6 @@ export class HeaderComponent implements OnInit {
searchValue = ''
ariaLabelTextForSearch = ''
private serverConfig: ServerConfig
constructor (
private router: Router,
private route: ActivatedRoute,
@ -38,23 +35,6 @@ export class HeaderComponent implements OnInit {
map(() => getParameterByName('search', window.location.href))
)
.subscribe(searchQuery => this.searchValue = searchQuery || '')
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig().subscribe(
config => this.serverConfig = config,
err => this.notifier.error(err.message)
)
}
get routerLink () {
if (this.isUserLoggedIn()) {
return [ '/videos/upload' ]
} else if (this.isRegistrationAllowed()) {
return [ '/signup' ]
} else {
return [ '/login', { fromUpload: true } ]
}
}
doSearch () {
@ -73,15 +53,6 @@ export class HeaderComponent implements OnInit {
o.subscribe(() => this.router.navigate([ '/search' ], { queryParams }))
}
isUserLoggedIn () {
return this.authService.isLoggedIn()
}
isRegistrationAllowed () {
return this.serverConfig.signup.allowed &&
this.serverConfig.signup.allowedForCurrentIP
}
private loadUserLanguagesIfNeeded (queryParams: any) {
if (queryParams && queryParams.languageOneOf) return of(queryParams)

View File

@ -3,15 +3,18 @@
Login
</div>
<div class="alert alert-warning" *ngIf="from.upload" role="alert">
<div class="alert alert-info" *ngIf="signupAllowed === false" role="alert">
<h6 class="alert-heading" i18n>
If you are looking for an account…
</h6>
<div i18n>
Currently this instance doesn't allow for user registration, but you can find an instance
Currently this instance doesn't allow for user registration, but you can find an instance
that gives you the possibility to sign up for an account and upload your videos there.
Find yours among multiple instances at <a class="alert-link" [href]="instancesIndexUrl" target="_blank" rel="noopener noreferrer">{{ instancesIndexUrl }}</a>
, a directory of instances recommended by this instance.
<br />
Find yours among multiple instances at <a class="alert-link" href="https://joinpeertube.org/instances" target="_blank" rel="noopener noreferrer">https://joinpeertube.org/instances</a>.
</div>
</div>
@ -30,16 +33,6 @@
<a i18n *ngIf="signupAllowed === true" routerLink="/signup" class="create-an-account">
or create an account
</a>
<a i18n *ngIf="signupAllowed === false" href="https://joinpeertube.org/instances#instances-list" target="_blank" title="Click here to see a list of instances where to register" class="create-an-account">
or create an account on another instance
</a>
<my-help *ngIf="signupAllowed === false">
<ng-template ptTemplate="customHtml">
<ng-container i18n>User registration is not allowed on this instance, but you can register on many others!</ng-container>
</ng-template>
</my-help>
</div>
<div *ngIf="formErrors.username" class="form-error">

View File

@ -22,9 +22,6 @@ export class LoginComponent extends FormReactive implements OnInit {
error: string = null
forgotPasswordEmail = ''
from = {
upload: false
}
private openedForgotPasswordModal: NgbModalRef
private serverConfig: ServerConfig
@ -47,17 +44,12 @@ export class LoginComponent extends FormReactive implements OnInit {
return this.serverConfig.signup.allowed === true
}
get instancesIndexUrl () {
return this.serverConfig.followings.instance.autoFollowIndex.indexUrl || 'https://instances.joinpeertube.org'
}
isEmailDisabled () {
return this.serverConfig.email.enabled === false
}
ngOnInit () {
this.serverConfig = this.route.snapshot.data.serverConfig
this.from.upload = Boolean(this.route.snapshot.paramMap.get('fromUpload'))
this.buildForm({
username: this.loginValidatorsService.LOGIN_USERNAME,