diff --git a/app/assets/javascripts/app/controllers/reset_password.js.coffee b/app/assets/javascripts/app/controllers/reset_password.js.coffee index 3e1710e2b..c2fb191b9 100644 --- a/app/assets/javascripts/app/controllers/reset_password.js.coffee +++ b/app/assets/javascripts/app/controllers/reset_password.js.coffee @@ -11,6 +11,11 @@ class Index extends App.Controller constructor: -> super + # go back if feature is not enabled + if !@Config.get('user_lost_password') + @navigate '#' + return + # set title @title 'Reset Password' @navupdate '#reset_password' diff --git a/app/assets/javascripts/app/controllers/signup.js.coffee b/app/assets/javascripts/app/controllers/signup.js.coffee index 314440c56..56ce68d15 100644 --- a/app/assets/javascripts/app/controllers/signup.js.coffee +++ b/app/assets/javascripts/app/controllers/signup.js.coffee @@ -11,6 +11,11 @@ class Index extends App.Controller constructor: -> super + # go back if feature is not enabled + if !@Config.get('user_create_account') + @navigate '#' + return + # set title @title 'Sign up' @navupdate '#signup' diff --git a/app/assets/javascripts/app/views/login.jst.eco b/app/assets/javascripts/app/views/login.jst.eco index b22332575..a3801a8a5 100644 --- a/app/assets/javascripts/app/views/login.jst.eco +++ b/app/assets/javascripts/app/views/login.jst.eco @@ -13,8 +13,10 @@
<%- @T( 'Remember me' ) %> + <% if @C('user_lost_password'): %> · <%- @T( 'Forgot password?' ) %> + <% end %>
@@ -39,6 +41,7 @@ <% end %> + <% if @C('user_create_account'): %>

--- <%- @T( 'or' ) %> ---

@@ -47,10 +50,11 @@
-

<%- @T( 'New to' ) %> <%= @C( 'product_name' ) %>, <%- @T( 'join today!' ) %>

+

<%- @T( 'New to %s join today!', @C( 'product_name' ) ) %>

<%- @T( 'Sign up' ) %>

+ <% end %>
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index c6c2fb349..9475698a2 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -21,6 +21,14 @@ class SessionsController < ApplicationController # auto population of default collections default_collection = SessionHelper::default_collections(user) + # remember me - set session cookie to expire later + reset_session + if params[:remember_me] + request.env['rack.session.options'][:expire_after] = 1.year.from_now + else + request.env['rack.session.options'][:expire_after] = nil + end + # set session user_id user = User.find_fulldata(user.id) session[:user_id] = user['id'] @@ -37,11 +45,6 @@ class SessionsController < ApplicationController ) end - # remember me - set session cookie to expire later - if params[:remember_me] - request.env['rack.session.options'][:expire_after] = 1.year.from_now - end - # return new session data render :json => { :session => user, diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 458334d39..a9e527d2d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -118,12 +118,18 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type user = User.new( User.param_cleanup(params) ) user.updated_by_id = (current_user && current_user.id) || 1 user.created_by_id = (current_user && current_user.id) || 1 - + begin # if it's a signup, add user to customer role if user.created_by_id == 1 + # check if feature is enabled + if !Setting.get('user_create_account') + render :json => { :error => 'Feature not enabled!' }, :status => :unprocessable_entity + return + end + # check if it's first user count = User.all.count() group_ids = [] @@ -311,6 +317,13 @@ curl http://localhost/api/users/password_reset.json -v -u #{login}:#{password} - =end def password_reset_send + + # check if feature is enabled + if !Setting.get('user_lost_password') + render :json => { :error => 'Feature not enabled!' }, :status => :unprocessable_entity + return + end + success = User.password_reset_send( params[:username] ) if success render :json => { :message => 'ok' }, :status => :ok