Add error when email system is not configured and using the forgot

password system
pull/1462/head
Chocobozzz 2018-12-05 15:10:45 +01:00
parent 56af5222c1
commit 3b3b18203f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 28 additions and 6 deletions

View File

@ -37,6 +37,9 @@ export class ServerService {
css: '' css: ''
} }
}, },
email: {
enabled: false
},
serverVersion: 'Unknown', serverVersion: 'Unknown',
signup: { signup: {
allowed: false, allowed: false,

View File

@ -59,7 +59,12 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group">
<div *ngIf="isEmailDisabled()" class="alert alert-danger" i18n>
We are sorry, you cannot recover you password because your instance administrator did not configure the PeerTube email system.
</div>
<div class="form-group" [hidden]="isEmailDisabled()">
<label i18n for="forgot-password-email">Email</label> <label i18n for="forgot-password-email">Email</label>
<input <input
type="email" id="forgot-password-email" i18n-placeholder placeholder="Email address" required type="email" id="forgot-password-email" i18n-placeholder placeholder="Email address" required

View File

@ -19,7 +19,6 @@ import { Router } from '@angular/router'
export class LoginComponent extends FormReactive implements OnInit { export class LoginComponent extends FormReactive implements OnInit {
@ViewChild('emailInput') input: ElementRef @ViewChild('emailInput') input: ElementRef
@ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef @ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef
@ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
error: string = null error: string = null
forgotPasswordEmail = '' forgotPasswordEmail = ''
@ -45,6 +44,10 @@ export class LoginComponent extends FormReactive implements OnInit {
return this.serverService.getConfig().signup.allowed === true return this.serverService.getConfig().signup.allowed === true
} }
isEmailDisabled () {
return this.serverService.getConfig().email.enabled === false
}
ngOnInit () { ngOnInit () {
this.buildForm({ this.buildForm({
username: this.loginValidatorsService.LOGIN_USERNAME, username: this.loginValidatorsService.LOGIN_USERNAME,
@ -96,10 +99,6 @@ export class LoginComponent extends FormReactive implements OnInit {
) )
} }
onForgotPasswordModalShown () {
this.forgotPasswordEmailInput.nativeElement.focus()
}
openForgotPasswordModal () { openForgotPasswordModal () {
this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal) this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal)
} }

View File

@ -11,6 +11,7 @@ import { ClientHtml } from '../../lib/client-html'
import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
import { remove, writeJSON } from 'fs-extra' import { remove, writeJSON } from 'fs-extra'
import { getServerCommit } from '../../helpers/utils' import { getServerCommit } from '../../helpers/utils'
import { Emailer } from '../../lib/emailer'
const packageJSON = require('../../../../package.json') const packageJSON = require('../../../../package.json')
const configRouter = express.Router() const configRouter = express.Router()
@ -61,6 +62,9 @@ async function getConfig (req: express.Request, res: express.Response) {
css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
} }
}, },
email: {
enabled: Emailer.Instance.isEnabled()
},
serverVersion: packageJSON.version, serverVersion: packageJSON.version,
serverCommit, serverCommit,
signup: { signup: {

View File

@ -14,6 +14,7 @@ class Emailer {
private static instance: Emailer private static instance: Emailer
private initialized = false private initialized = false
private transporter: Transporter private transporter: Transporter
private enabled = false
private constructor () {} private constructor () {}
@ -50,6 +51,8 @@ class Emailer {
tls, tls,
auth auth
}) })
this.enabled = true
} else { } else {
if (!isTestInstance()) { if (!isTestInstance()) {
logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!') logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
@ -57,6 +60,10 @@ class Emailer {
} }
} }
isEnabled () {
return this.enabled
}
async checkConnectionOrDie () { async checkConnectionOrDie () {
if (!this.transporter) return if (!this.transporter) return

View File

@ -15,6 +15,10 @@ export interface ServerConfig {
} }
} }
email: {
enabled: boolean
}
signup: { signup: {
allowed: boolean, allowed: boolean,
allowedForCurrentIP: boolean, allowedForCurrentIP: boolean,