Permalink
Browse files

Implemented option to disable registration

  • Loading branch information...
fluidblue committed Nov 19, 2017
1 parent f0a9fa8 commit 125e7c347636a18bc97ebda07c6d8e8cf4053511
View
@@ -56,6 +56,8 @@ Save your configuration to a file, e.g. config.json:
"mail": "noreply@example.com",
"domain": "www.example.com",
"registrationEnabled": true,
"verbose": false
}
@@ -56,6 +56,14 @@
text-align: justify;
}
#register
{
.registrationClosed
{
text-align: center;
}
}
#frontpage
{
.logo
@@ -30,4 +30,6 @@
<button type="submit" id="registerButton" class="btn btn-success btnWide pull-right">Register</button>
<button type="submit" id="resetButton" class="btn btn-danger btnWide pull-right hide">Reset</button>
<div class="registrationClosed hide"></div>
</form>
View
@@ -166,4 +166,7 @@
<div class="inactivity">
You have been logged out, because you were inactive for %1 minutes.
</div>
<div class="registrationClosed">
The registration is currently closed.
</div>
</div>
@@ -17,6 +17,12 @@ credentials =
session: null
password: null
features = (callback) ->
# Send command to server
command.send
cmd: "user.features"
callback: callback
create = (email, password, passwordHint, callback) ->
# Create key from password and email address as salt.
# This key is salted and hashed again on the server, using a random salt.
@@ -153,6 +159,7 @@ getPassword = ->
return credentials.password
module.exports.features = features
module.exports.create = create
module.exports.updateEmail = updateEmail
module.exports.updatePassword = updatePassword
@@ -125,5 +125,17 @@ init = ->
register()
return
core.user.features (response) ->
if response.status == "success"
if !response.registration
# Disable registration
$("#register > .itemField").hide()
$("#register > .btn").hide()
# Show registration closed message
infoBox = $("#register > .registrationClosed")
infoBox.text global.text.get("registrationClosed")
infoBox.removeClass("hide")
module.exports.init = init
module.exports.validate = validate
@@ -20,6 +20,6 @@ core = require "./core"
# Initialize GUI when DOM is ready
$(document).ready ->
gui.init()
core.init()
gui.init()
return
@@ -21,6 +21,8 @@ process = (clientID, params, callback) ->
callback(result)
switch params.cmd
when "user.features"
user.features(callback)
when "user.create"
user.create(params.data.email, params.data.key, params.data.passwordHint, callback)
when "user.login"
@@ -30,6 +30,8 @@ defaultConfig =
mail: "noreply@example.com"
domain: "www.example.com"
registrationEnabled: true
verbose: false
get = ->
View
@@ -13,7 +13,19 @@ log = require "./log"
item = require "./item"
shared = require "./shared"
features = (callback) ->
callback
status: "success"
registration: config.get().registrationEnabled
create = (email, key, passwordHint, callback) ->
# Check if registration is enabled on the server
if !config.get().registrationEnabled
callback
status: "invalidcommand"
return
# Validate email and passwordHint
if !shared.validation.email(email) || !shared.validation.passwordHint(passwordHint)
callback
@@ -402,6 +414,7 @@ sendPasswordHint = (email, callback) ->
callback
status: "success"
module.exports.features = features
module.exports.create = create
module.exports.update = update
module.exports.reset = reset

0 comments on commit 125e7c3

Please sign in to comment.