Merge pull request #317 from SISheogorath/master+allowEmailRegister
Add `allowemailregister` option
This commit is contained in:
commit
4851098477
5 changed files with 35 additions and 28 deletions
|
@ -150,7 +150,8 @@ Environment variables (will overwrite other server configs)
|
||||||
| HMD_LDAP_TLS_CA | no example | Root CA for LDAP TLS in PEM format |
|
| HMD_LDAP_TLS_CA | no example | Root CA for LDAP TLS in PEM format |
|
||||||
| HMD_LDAP_PROVIDERNAME | My institution | Optional name to be displayed at login form indicating the LDAP provider |
|
| HMD_LDAP_PROVIDERNAME | My institution | Optional name to be displayed at login form indicating the LDAP provider |
|
||||||
| HMD_IMGUR_CLIENTID | no example | Imgur API client id |
|
| HMD_IMGUR_CLIENTID | no example | Imgur API client id |
|
||||||
| HMD_EMAIL | `true` or `false` | set to allow email register and signin |
|
| HMD_EMAIL | `true` or `false` | set to allow email signin |
|
||||||
|
| HMD_ALLOW_EMAIL_REGISTER | `true` or `false` | set to allow email register |
|
||||||
| HMD_IMAGE_UPLOAD_TYPE | `imgur`, `s3` or `filesystem` | Where to upload image. For S3, see our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) |
|
| HMD_IMAGE_UPLOAD_TYPE | `imgur`, `s3` or `filesystem` | Where to upload image. For S3, see our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) |
|
||||||
| HMD_S3_ACCESS_KEY_ID | no example | AWS access key id |
|
| HMD_S3_ACCESS_KEY_ID | no example | AWS access key id |
|
||||||
| HMD_S3_SECRET_ACCESS_KEY | no example | AWS secret key |
|
| HMD_S3_SECRET_ACCESS_KEY | no example | AWS secret key |
|
||||||
|
@ -194,7 +195,8 @@ Server settings `config.json`
|
||||||
| heartbeatinterval | `5000` | socket.io heartbeat interval |
|
| heartbeatinterval | `5000` | socket.io heartbeat interval |
|
||||||
| heartbeattimeout | `10000` | socket.io heartbeat timeout |
|
| heartbeattimeout | `10000` | socket.io heartbeat timeout |
|
||||||
| documentmaxlength | `100000` | note max length |
|
| documentmaxlength | `100000` | note max length |
|
||||||
| email | `true` or `false` | set to allow email register and signin |
|
| email | `true` or `false` | set to allow email signin |
|
||||||
|
| allowemailregister | `true` or `false` | set to allow email register |
|
||||||
| imageUploadType | `imgur`(default), `s3` or `filesystem` | Where to upload image
|
| imageUploadType | `imgur`(default), `s3` or `filesystem` | Where to upload image
|
||||||
| s3 | `{ "accessKeyId": "YOUR_S3_ACCESS_KEY_ID", "secretAccessKey": "YOUR_S3_ACCESS_KEY", "region": "YOUR_S3_REGION", "bucket": "YOUR_S3_BUCKET_NAME" }` | When `imageUploadType` be setted to `s3`, you would also need to setup this key, check our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) |
|
| s3 | `{ "accessKeyId": "YOUR_S3_ACCESS_KEY_ID", "secretAccessKey": "YOUR_S3_ACCESS_KEY", "region": "YOUR_S3_REGION", "bucket": "YOUR_S3_BUCKET_NAME" }` | When `imageUploadType` be setted to `s3`, you would also need to setup this key, check our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) |
|
||||||
|
|
||||||
|
|
2
app.js
2
app.js
|
@ -395,6 +395,7 @@ if (config.ldap) {
|
||||||
}
|
}
|
||||||
// email auth
|
// email auth
|
||||||
if (config.email) {
|
if (config.email) {
|
||||||
|
if (config.allowemailregister)
|
||||||
app.post('/register', urlencodedParser, function (req, res, next) {
|
app.post('/register', urlencodedParser, function (req, res, next) {
|
||||||
if (!req.body.email || !req.body.password) return response.errorBadRequest(res);
|
if (!req.body.email || !req.body.password) return response.errorBadRequest(res);
|
||||||
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res);
|
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res);
|
||||||
|
@ -423,6 +424,7 @@ if (config.email) {
|
||||||
return response.errorInternalError(res);
|
return response.errorInternalError(res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/login', urlencodedParser, function (req, res, next) {
|
app.post('/login', urlencodedParser, function (req, res, next) {
|
||||||
if (!req.body.email || !req.body.password) return response.errorBadRequest(res);
|
if (!req.body.email || !req.body.password) return response.errorBadRequest(res);
|
||||||
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res);
|
if (!validator.isEmail(req.body.email)) return response.errorBadRequest(res);
|
||||||
|
|
|
@ -132,6 +132,7 @@ if (process.env.HMD_LDAP_PROVIDERNAME) {
|
||||||
}
|
}
|
||||||
var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false;
|
var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false;
|
||||||
var email = process.env.HMD_EMAIL ? (process.env.HMD_EMAIL === 'true') : !!config.email;
|
var email = process.env.HMD_EMAIL ? (process.env.HMD_EMAIL === 'true') : !!config.email;
|
||||||
|
var allowemailregister = process.env.HMD_ALLOW_EMAIL_REGISTER ? (process.env.HMD_HMD_ALLOW_EMAIL_REGISTER === 'true') : !!config.allowemailregister;
|
||||||
|
|
||||||
function getserverurl() {
|
function getserverurl() {
|
||||||
var url = '';
|
var url = '';
|
||||||
|
@ -194,6 +195,7 @@ module.exports = {
|
||||||
ldap: ldap,
|
ldap: ldap,
|
||||||
imgur: imgur,
|
imgur: imgur,
|
||||||
email: email,
|
email: email,
|
||||||
|
allowemailregister: allowemailregister,
|
||||||
imageUploadType: imageUploadType,
|
imageUploadType: imageUploadType,
|
||||||
s3: s3,
|
s3: s3,
|
||||||
s3bucket: s3bucket
|
s3bucket: s3bucket
|
||||||
|
|
|
@ -68,6 +68,7 @@ function showIndex(req, res, next) {
|
||||||
google: config.google,
|
google: config.google,
|
||||||
ldap: config.ldap,
|
ldap: config.ldap,
|
||||||
email: config.email,
|
email: config.email,
|
||||||
|
allowemailregister: config.allowemailregister,
|
||||||
signin: req.isAuthenticated(),
|
signin: req.isAuthenticated(),
|
||||||
infoMessage: req.flash('info'),
|
infoMessage: req.flash('info'),
|
||||||
errorMessage: req.flash('error')
|
errorMessage: req.flash('error')
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<button type="submit" class="btn btn-primary" formaction="<%- url %>/login">Sign in</button>
|
<button type="submit" class="btn btn-primary" formaction="<%- url %>/login">Sign in</button>
|
||||||
<button type="submit" class="btn btn-default" formaction="<%- url %>/register">Register</button>
|
<% if(allowemailregister) { %><button type="submit" class="btn btn-default" formaction="<%- url %>/register">Register</button><% }%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue