server/password-reset: support having no smtp

This commit is contained in:
rr- 2017-02-17 23:08:37 +01:00
parent 32d15a493c
commit c01214e919
5 changed files with 45 additions and 24 deletions

View file

@ -0,0 +1,2 @@
#password-reset
max-width: 30em

View file

@ -30,9 +30,7 @@
<div class='buttons'> <div class='buttons'>
<input type='submit' value='Log in'/> <input type='submit' value='Log in'/>
<% if (ctx.canSendMails) { %> <a class='append' href='<%- ctx.formatClientLink('password-reset') %>'>Forgot the password?</a>
<a class='append' href='<%- ctx.formatClientLink('password-reset') %>'>Forgot the password?</a>
<% } %>
</div> </div>
</form> </form>
</div> </div>

View file

@ -1,23 +1,30 @@
<div class='content-wrapper' id='password-reset'> <div class='content-wrapper' id='password-reset'>
<h1>Password reset</h1> <h1>Password reset</h1>
<form autocomplete='off'> <% if (ctx.canSendMails) { %>
<ul class='input'> <form autocomplete='off'>
<li> <ul class='input'>
<%= ctx.makeTextInput({ <li>
text: 'User name or e-mail address', <%= ctx.makeTextInput({
name: 'user-name', text: 'User name or e-mail address',
required: true, name: 'user-name',
}) %> required: true,
</li> }) %>
</ul> </li>
</ul>
<p><small>Proceeding will send an e-mail that contains a password reset <p><small>Proceeding will send an e-mail that contains a password reset
link. Clicking it is going to generate a new password for your account. link. Clicking it is going to generate a new password for your account.
It is recommended to change that password to something else.</small></p> It is recommended to change that password to something else.</small></p>
<div class='messages'></div> <div class='messages'></div>
<div class='buttons'> <div class='buttons'>
<input type='submit' value='Proceed'/> <input type='submit' value='Proceed'/>
</div> </div>
</form> </form>
<% } else { %>
<p>We do not support automatic password resetting.</p>
<% if (ctx.contactEmail) { %>
<p>Please send an e-mail to <a href='mailto:<%- ctx.contactEmail %>'><%- ctx.contactEmail %></a> to go through a manual procedure.</p>
<% } %>
<% } %>
</div> </div>

View file

@ -1,5 +1,6 @@
'use strict'; 'use strict';
const config = require('../config.js');
const events = require('../events.js'); const events = require('../events.js');
const views = require('../util/views.js'); const views = require('../util/views.js');
@ -10,7 +11,10 @@ class PasswordResetView extends events.EventTarget {
super(); super();
this._hostNode = document.getElementById('content-holder'); this._hostNode = document.getElementById('content-holder');
views.replaceContent(this._hostNode, template()); views.replaceContent(this._hostNode, template({
canSendMails: config.canSendMails,
contactEmail: config.contactEmail,
}));
views.syncScrollPosition(); views.syncScrollPosition();
views.decorateValidator(this._formNode); views.decorateValidator(this._formNode);

View file

@ -25,12 +25,18 @@ thumbnails:
post_width: 300 post_width: 300
post_height: 300 post_height: 300
# used to send password reminders
# used to send password reset e-mails
smtp: smtp:
host: # example: localhost host: # example: localhost
port: # example: 25 port: # example: 25
user: # example: bot user: # example: bot
pass: # example: groovy123 pass: # example: groovy123
# host can be left empty, in which case it is recommended to fill contactEmail.
contactEmail: # example: bob@example.com. Meant for manual password reset procedures
# used for reverse image search # used for reverse image search
elasticsearch: elasticsearch:
@ -38,15 +44,16 @@ elasticsearch:
port: 9200 port: 9200
index: szurubooru index: szurubooru
limits: limits:
users_per_page: 20 users_per_page: 20
posts_per_page: 40 posts_per_page: 40
max_comment_length: 5000 max_comment_length: 5000
tag_name_regex: ^\S+$ tag_name_regex: ^\S+$
tag_category_name_regex: ^[^\s%+#/]+$ tag_category_name_regex: ^[^\s%+#/]+$
default_rank: regular
# don't change these, unless you want to annoy people. if you do customize # don't change these, unless you want to annoy people. if you do customize
# them though, make sure to update the instructions in the registration form # them though, make sure to update the instructions in the registration form
@ -54,6 +61,9 @@ default_rank: regular
password_regex: '^.{5,}$' password_regex: '^.{5,}$'
user_name_regex: '^[a-zA-Z0-9_-]{1,32}$' user_name_regex: '^[a-zA-Z0-9_-]{1,32}$'
default_rank: regular
privileges: privileges:
'users:create': anonymous 'users:create': anonymous
'users:list': regular 'users:list': regular