Use settings params to check if password reset and new user creation is enbled.
This commit is contained in:
parent
ee77792db4
commit
c34240c74d
5 changed files with 37 additions and 7 deletions
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
<button class="btn btn-primary" type="submit"><%- @T( 'Sign in' ) %></button>
|
||||
<div>
|
||||
<span class="small"><input name="remember_me" value="1" type="checkbox"/> <%- @T( 'Remember me' ) %></span>
|
||||
<% if @C('user_lost_password'): %>
|
||||
<span class="small">·</span>
|
||||
<a href="#reset_password" class="small"><%- @T( 'Forgot password?' ) %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -39,6 +41,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @C('user_create_account'): %>
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<p>--- <%- @T( 'or' ) %> ---</p>
|
||||
|
@ -47,10 +50,11 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<p><%- @T( 'New to' ) %> <%= @C( 'product_name' ) %>, <%- @T( 'join today!' ) %></p>
|
||||
<p><%- @T( 'New to %s join today!', @C( 'product_name' ) ) %></p>
|
||||
<p><a href="#signup" class="btn"><%- @T( 'Sign up' ) %></a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue