修改各个页面验证绑定登录的方式。
This commit is contained in:
parent
762fdfe634
commit
2b7ff3c76b
|
@ -27,7 +27,8 @@ module Mobile
|
|||
post 'wxbind' do
|
||||
openid = session[:wechat_openid]
|
||||
logger.debug "openid ============== #{openid}"
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
raise "请在微信中关注公众号'Trustie创新实践平台'后再打开本页面" unless openid
|
||||
uw = UserWechat.where(openid: openid).first
|
||||
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
|
||||
|
||||
|
@ -56,7 +57,8 @@ module Mobile
|
|||
|
||||
openid = session[:wechat_openid]
|
||||
logger.debug "openid ============== #{openid}"
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
||||
|
||||
|
||||
us = UsersService.new
|
||||
|
|
|
@ -284,7 +284,7 @@ class WechatsController < ActionController::Base
|
|||
end
|
||||
|
||||
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
|
||||
content: "课程名称:#{course.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
|
||||
content: "课程名称:#{course.syllabus.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
|
||||
return request.reply.news(news) do |article, n, index| # article is return object
|
||||
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
|
||||
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
|
||||
|
@ -333,7 +333,9 @@ class WechatsController < ActionController::Base
|
|||
code = params[:code] || session[:wechat_code]
|
||||
openid = get_openid_from_code(code)
|
||||
|
||||
raise "无法获取到微信openid" unless openid
|
||||
# raise "无法获取到微信openid" unless openid
|
||||
|
||||
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
||||
|
||||
uw = UserWechat.where(openid: openid).first
|
||||
raise "还未绑定trustie帐户" unless uw
|
||||
|
@ -349,13 +351,25 @@ class WechatsController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def is_bind
|
||||
begin
|
||||
code = params[:code] || session[:wechat_code]
|
||||
open_id = get_openid_from_code(code)
|
||||
raise "还未绑定trustie帐户" unless user_binded?(open_id)
|
||||
render :json => {status: 0}
|
||||
rescue Exception=>e
|
||||
render :json => {status: -1, message: e.message}
|
||||
end
|
||||
end
|
||||
|
||||
def bind
|
||||
begin
|
||||
|
||||
code = params[:code] || session[:wechat_code]
|
||||
openid = get_openid_from_code(code)
|
||||
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
||||
raise "此微信号已绑定用户,不能重复绑定" if user_binded?(openid)
|
||||
|
||||
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||
|
@ -399,9 +413,9 @@ class WechatsController < ActionController::Base
|
|||
render 'wechats/open_wechat', layout: nil and return
|
||||
end
|
||||
|
||||
unless user_binded?(open_id)
|
||||
@path = '/login'
|
||||
else
|
||||
# unless user_binded?(open_id)
|
||||
# @path = '/login'
|
||||
# else
|
||||
if params[:state] == 'myclass'
|
||||
@course_id = params[:id];
|
||||
elsif params[:state] == 'myproject'
|
||||
|
@ -412,7 +426,7 @@ class WechatsController < ActionController::Base
|
|||
if params[:code]
|
||||
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||
end
|
||||
end
|
||||
# end
|
||||
render 'wechats/user_activities', layout: nil
|
||||
end
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}:", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
|
||||
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -239,7 +239,12 @@ class ProjectsService
|
|||
if apply_message
|
||||
if user.member_of?(project)
|
||||
message = "已经是该项目的成员了"
|
||||
applied_messages.update_all(:status=>7)
|
||||
u_member = project.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
|
||||
if u_member.member_roles[0].role_id == 5
|
||||
applied_messages.update_all(:status=>5)
|
||||
else
|
||||
applied_messages.update_all(:status=>7)
|
||||
end
|
||||
else
|
||||
applied_project = apply_message.applied
|
||||
ap_role = applied_project.try(:role)
|
||||
|
|
|
@ -1325,6 +1325,7 @@ RedmineApp::Application.routes.draw do
|
|||
get :user_activities
|
||||
post :bind
|
||||
post :get_bind
|
||||
post :is_bind
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
<li><span class="fl ml10 class-list-name hidden">开发人员</span><span ng-click="selectRole(4)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 4}]"></span></li>
|
||||
<li class="border-bottom-none"><span class="fl ml10 class-list-name hidden">报告人员</span><span ng-click="selectRole(5)" ng-class="['login-box', 'fr', 'mr10', 'mt12','img-circle', {'checked': role_id == 5}]"></span></li>
|
||||
</ul>
|
||||
<div class="f12 c-grey6 mt10 ml15">
|
||||
<span class="f13 c-grey3">提示</span>
|
||||
<ul class="mb15 mt5 ml10 new-tip">
|
||||
<li><span class="project-intro-dot">•</span>管理人员、开发人员角色需要项目管理员审批</li>
|
||||
<li><span class="project-intro-dot">•</span>报告人员角色无需管理员审批</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="bottom-tab-wrap mt10">
|
||||
<a href="javascript:void(0);" ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
|
||||
<a href="javascript:void(0);" ng-click="join_project()" class="weixin-tab link-blue2 border-top">确定</a>
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
app.controller('ActivityController',
|
||||
['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common','alertService',
|
||||
function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common, alertService){
|
||||
|
||||
common.checklogin();
|
||||
|
||||
|
||||
$scope.replaceUrl = function(url){
|
||||
return url;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){
|
||||
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
var courseid = $routeParams.id;
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
*/
|
||||
|
||||
|
||||
app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService','rms',
|
||||
function ($scope, config, auth, $http, $location, alertService,rms) {
|
||||
app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService','rms','common'
|
||||
function ($scope, config, auth, $http, $location, alertService,rms,common) {
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
vm.syllabuses = rms.get('syllabuses') || [];
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
vm.syllabus = rms.get('current_edit_syllobus');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
app.controller('EditClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('EditProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
app.controller('EditProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx){
|
||||
app.controller('JoinClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('JoinProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx){
|
||||
app.controller('JoinProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','wx','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,wx,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$location', 'rms', function($scope, $http, auth, config, $location,rms){
|
||||
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$location', 'rms','common', function($scope, $http, auth, config, $location,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
// vm.menus = ['课件', '作业', '测验'];
|
||||
vm.menus = ['课件', '作业'];
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms', function($scope, $http, auth, config, alertService, $location,rms){
|
||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms','common', function($scope, $http, auth, config, alertService, $location,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('NewProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms', function($scope, $http, auth, config, alertService, $location,rms){
|
||||
app.controller('NewProjectController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms','common', function($scope, $http, auth, config, alertService, $location,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'auth','$location','$routeParams','alertService','rms','common', function($scope, config, $http,$timeout, auth, $location, $routeParams,alertService,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
$scope.replaceUrl = function(url){
|
||||
return url;
|
||||
};
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
*/
|
||||
|
||||
|
||||
app.controller('ProjectListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService','rms',
|
||||
function ($scope, config, auth, $http, $location, alertService,rms) {
|
||||
app.controller('ProjectListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService','rms','common',
|
||||
function ($scope, config, auth, $http, $location, alertService,rms,common) {
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
// vm.projects = rms.get('projects') || [];
|
||||
vm.projects = [];
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('ReviewClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
app.controller('ReviewClassMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
|
||||
app.controller('ReviewProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms', function($scope, $http, auth, config, alertService, $location,$routeParams, rms){
|
||||
app.controller('ReviewProjectMemberController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','$routeParams','rms','common', function($scope, $http, auth, config, alertService, $location,$routeParams, rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
|
||||
// vm.current_edit_member = rms.get('current_edit_member');
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'config','auth','alertService', 'rms', function($scope, $http, $routeParams, config, auth, alertService,rms){
|
||||
app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'config','auth','alertService', 'rms','common', function($scope, $http, $routeParams, config, auth, alertService,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
var send_id = $routeParams.id;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ app.factory('rms', function(){
|
|||
return {save: save, get: get};
|
||||
});
|
||||
|
||||
app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', function($http, auth, $routeParams,rms,config,wx){
|
||||
app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){
|
||||
var addCommonReply = function(id, type, data, cb){
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
|
@ -390,5 +390,18 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx', func
|
|||
});
|
||||
};
|
||||
|
||||
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig};
|
||||
var checkLogin = function(){
|
||||
$http.post(
|
||||
'/wechat/is_bind',
|
||||
{} ///不用传code了,都由服务器来处理
|
||||
).then(function(response){
|
||||
console.log(response.data);
|
||||
if(response.data.status != 0){
|
||||
$location.path("/login");
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin};
|
||||
}]);
|
||||
|
|
Loading…
Reference in New Issue