Commit 68e18c18 authored by Nicholas J Anderson's avatar Nicholas J Anderson
Browse files

Implemented Login through CAS

parent 58fdf140
......@@ -8,3 +8,5 @@ iron:router
ewall:foundation
aldeed:collection2
alanning:roles
atoy40:accounts-cas
......@@ -3,6 +3,7 @@ alanning:roles@1.2.13
aldeed:collection2@2.2.0
aldeed:simple-schema@1.0.3
application-configuration@1.0.3
atoy40:accounts-cas@0.0.2
autoupdate@1.1.3
base64@1.0.1
binary-heap@1.0.1
......
<template name="loginForm">
<div id="loginFormDiv">
<form id="loginForm">
<input type="text" id="username-field" placeholder="Username"/>
<br/>
<input type="text" id="password-field" placeholder="Password"/>
<br>
<input type="submit" value="Login">
</form>
<button id="login">Login!</button>
</div>
</template>
Template.loginForm.events({
'submit #loginForm': function(e, t) {
var username = $('#username-field').value;
var password = $('#password-field')
'click #login': function() {
Meteor.loginWithCas(function(a, b, c) {
Router.go(this.route.handler.name);
});
}
});
});
\ No newline at end of file
......@@ -57,7 +57,7 @@ Messages.attachSchema(Schemas.Message);
if(Meteor.isServer) {
Meteor.publish('channels', function() {
//Get UserId
var curUserId = Meteor.userId();
var curUserId = this.userId;
//Get the ChannelMemberships for the user
var channelAsso = ChannelMemberships.find({userId: curUserId}).fetch();
......@@ -70,14 +70,14 @@ if(Meteor.isServer) {
});
Meteor.publish('messages', function() {
//Get UserId
var curUserId = Meteor.userId();
var curUserId = this.userId;
//Get the messages
var messages = Messages.find({$or: [{$or: [{senderId: curUserId}, {receiverId: curUserId}]}, {isPrivate: false}]}).fetch();
return messages;
});
Meteor.publish('channelMemberships', function() {
return ChannelMemberships.find({userId: Meteor.userId()}).fetch();
return ChannelMemberships.find({userId: this.userId}).fetch();
});
//Allow Statements
......
{
"cas": {
"baseUrl": "https://login.gmu.edu/",
"autoClose": true
},
"public": {
"cas": {
"loginUrl": "https://login.gmu.edu/login",
"serviceParam": "service",
"popupWidth": 810,
"popupHeight": 610
}
}
}
function LoginCtrl() {
console.log(this);
if (Meteor.userId()) {
Router.go('/')
}
this.render('loginForm')
}
Router.configure({
layoutTemplate: 'contentLayout'
});
Router.onAfterAction(function() {
$(document).foundation('topbar', 'init')
}, {where:'client'})
// User login hook
Router.onBeforeAction(function() {
if (!Meteor.userId()) {
LoginCtrl.call(this);
} else {
this.next();
}
}, {
'except': [
// 'about',
'user.login'
]
});
//Landing Page
Router.route('/', function() {
this.render('landing');
}, {
'name': 'landing'
});
Router.route('/login', LoginCtrl, {
'name': 'user.login'
});
// TODO: We want to protect this with a logout key
// because <img src="/logout">
Router.route('/logout', function() {
Meteor.logout(function() {
Router.go('/login')
});
}, {
'name': 'user.logout'
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment