Merge branch 'session_goback'

This commit is contained in:
yafeilee 2014-04-03 11:14:11 +08:00
commit 9dc427bfe6
3 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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