Merge branch 'session_goback'
This commit is contained in:
commit
9dc427bfe6
|
@ -1,4 +1,4 @@
|
|||
@app.controller 'AdminSessionsController', [ '$scope', '$http', '$timeout', ($scope, $http, $timeout)->
|
||||
@app.controller 'AdminSessionsController', [ '$scope', '$http', '$timeout', '$cookies', ($scope, $http, $timeout, $cookies)->
|
||||
url = '/admin/sessions'
|
||||
|
||||
$scope.login = ->
|
||||
|
@ -10,7 +10,8 @@
|
|||
password: $scope.password
|
||||
.success (res)->
|
||||
if res.success
|
||||
window.location = '/admin'
|
||||
urlback = $cookies.urlback || 'admin'
|
||||
window.location = urlback
|
||||
else
|
||||
$scope.password = ''
|
||||
$scope.error_msg = res.message
|
||||
|
|
|
@ -12,6 +12,7 @@ class Admin::SessionsController < ApplicationController
|
|||
elsif ENV['ADMIN_PASSWORD'] != params[:password]
|
||||
render :json=> { success: false, message: '管理员密码错误' }
|
||||
else
|
||||
flash[:notice] = '登录成功'
|
||||
session[:login] = true
|
||||
render :json=> { success: true }
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@ class ApplicationController < ActionController::Base
|
|||
def authericate_user!
|
||||
if ! session[:login]
|
||||
flash[:error] = '请先登录后台管理'
|
||||
cookies[:urlback] = request.original_url
|
||||
redirect_to new_admin_session_path
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue