解决没绑定用户不跳转到绑定页问题
This commit is contained in:
parent
5bd3e98f56
commit
9d2900d58f
2
Gemfile
2
Gemfile
|
@ -51,7 +51,7 @@ gem 'elasticsearch-rails'
|
|||
|
||||
|
||||
### profile
|
||||
gem 'oneapm_rpm'
|
||||
# gem 'oneapm_rpm'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
|
|
|
@ -43,9 +43,9 @@ module Mobile
|
|||
end
|
||||
|
||||
def current_user
|
||||
openid = params[:openid]
|
||||
openid = session[:wechat_openid]
|
||||
if openid
|
||||
uw = UserWechat.find_by_openid(params[:openid])
|
||||
uw = UserWechat.find_by_openid(openid)
|
||||
return uw.user if uw
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#coding=utf-8
|
||||
#
|
||||
module Mobile
|
||||
module Exceptions
|
||||
class AuthException < StandardError
|
||||
attr_reader :err_code, :msg
|
||||
def initialize(code, msg)
|
||||
@err_code = code
|
||||
@msg = msg
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +1,6 @@
|
|||
#coding=utf-8
|
||||
|
||||
|
||||
module Mobile
|
||||
module Middleware
|
||||
class ErrorHandler < Grape::Middleware::Base
|
||||
|
@ -6,7 +9,10 @@ module Mobile
|
|||
begin
|
||||
@app.call(@env)
|
||||
rescue =>e
|
||||
message = {status: 1, message: e.message }.to_json
|
||||
code = 1
|
||||
|
||||
message = {status: code, message: e.message }.to_json
|
||||
|
||||
Rails.logger.error e.inspect
|
||||
Rails.logger.error e.backtrace.join("\n")
|
||||
status = 200
|
||||
|
|
|
@ -288,8 +288,7 @@ class WechatsController < ActionController::Base
|
|||
session[:wechat_code] = params[:code] if params[:code]
|
||||
openid = get_openid_from_code(params[:code])
|
||||
@wechat_user = user_binded?(openid)
|
||||
|
||||
render 'wechats/login', layout: 'base_wechat'
|
||||
render 'wechats/user_activities', layout: nil
|
||||
end
|
||||
|
||||
def user_activities
|
||||
|
@ -299,13 +298,18 @@ class WechatsController < ActionController::Base
|
|||
unless open_id
|
||||
render 'wechats/open_wechat', layout: nil and return
|
||||
end
|
||||
if params[:state] == 'myclass'
|
||||
@course_id = params[:id];
|
||||
end
|
||||
|
||||
unless user_binded?(open_id)
|
||||
@path = '/login'
|
||||
else
|
||||
if params[:state] == 'myclass'
|
||||
@course_id = params[:id];
|
||||
end
|
||||
|
||||
session[:wechat_openid] = open_id
|
||||
if params[:code]
|
||||
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||
session[:wechat_openid] = open_id
|
||||
if params[:code]
|
||||
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||
end
|
||||
end
|
||||
render 'wechats/user_activities', layout: nil
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Redmine
|
|||
def acts_as_watchable(options = {})
|
||||
return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
|
||||
class_eval do
|
||||
has_many :watchers, :as => :watchable, :dependent => :delete_all
|
||||
has_many :watchers, :dependent => :delete_all
|
||||
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
|
||||
|
||||
scope :watched_by, lambda { |user_id|
|
||||
|
|
|
@ -60,7 +60,7 @@ app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function(
|
|||
}
|
||||
|
||||
var getToken = function(){
|
||||
return session.get("token");
|
||||
return 'token';//session.get("token");
|
||||
}
|
||||
return {get_bind: isBind, token: getToken};
|
||||
}]);
|
||||
|
@ -300,4 +300,4 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config', function(
|
|||
}
|
||||
|
||||
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
|
||||
}]);
|
||||
}]);
|
||||
|
|
|
@ -8,8 +8,8 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
|
|||
var makeRoute = function(path, ctrl){
|
||||
return {
|
||||
templateUrl: rootPath + path,
|
||||
controller: ctrl,
|
||||
resolve: resolve
|
||||
controller: ctrl
|
||||
//resolve: resolve
|
||||
}
|
||||
}
|
||||
//$locationProvider.html5Mode(true);
|
||||
|
@ -59,6 +59,14 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
|
|||
return rejection;
|
||||
},
|
||||
response: function (response) {
|
||||
// var data = response.data;
|
||||
// if(data && data.status==405){
|
||||
// var rootScope = $injector.get('$rootScope');
|
||||
// var state = $injector.get('$rootScope').$state.current.name;
|
||||
// rootScope.stateBeforLogin = state;
|
||||
// rootScope.$state.go("login");
|
||||
// return $q.reject(response);
|
||||
// }
|
||||
$rootScope.activeCalls -= 1;
|
||||
return response;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue