forked from egerlach/fedbus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the beginnings of a login/registration system
refs #7 The first thing is to add a userid column to the database. Yeah, forgot that. Sort of necessary for users We also added were some utility functions to the Application Controller. These allow us to check to see if someone is logged in, and if not, redirect to the login url. We also added a login route to the routes. In the users controller, add login and logout actions. Only login is implemented, which redirects to CAS for the login. Also, this commit fixes up the functional tests for the users controller which were previously broken.
- Loading branch information
Showing
6 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddUseridToUser < ActiveRecord::Migration | ||
def self.up | ||
add_column :users, :userid, :string | ||
end | ||
|
||
def self.down | ||
remove_column :users, :userid | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,16 @@ tester: | |
last_name: Tester | ||
email: [email protected] | ||
student_number_hash: 7e071fd9b023ed8f18458a73613a0834f6220bd5cc50357ba3493c6040a9ea8c | ||
userid: test | ||
one: | ||
first_name: One | ||
last_name: Onesie | ||
email: [email protected] | ||
student_number_hash: 7e071fd9b023ed8f18458a73613a0834f6220bd5cc50357ba3493c6040a9ea8c | ||
userid: one | ||
two: | ||
first_name: Two | ||
last_name: Twofer | ||
email: [email protected] | ||
student_number_hash: 7e071fd9b023ed8f18458a73613a0834f6220bd5cc50357ba3493c6040a9ea8c | ||
userid: two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,13 @@ class UsersControllerTest < ActionController::TestCase | |
|
||
test "should create user" do | ||
assert_difference('User.count') do | ||
post :create, :user => { } | ||
post :create, :user => { | ||
:first_name => 'Test', | ||
:last_name => 'Tester', | ||
:student_number => '00000000', | ||
:student_number_confirmation => '00000000', | ||
:email => '[email protected]' | ||
} | ||
end | ||
|
||
assert_redirected_to user_path(assigns(:user)) | ||
|
@@ -42,4 +48,19 @@ class UsersControllerTest < ActionController::TestCase | |
|
||
assert_redirected_to users_path | ||
end | ||
|
||
test "login should redirect to CAS if not logged in" do | ||
get :login | ||
assert_redirected_to 'https://cas.uwaterloo.ca/cas/login?service=http%3A%2F%2Ftest.host%2Flogin' | ||
end | ||
|
||
test "login should redirect to root if logged in" do | ||
get :login, nil, {:cas_user => "test"} | ||
assert_redirected_to "http://test.host/" | ||
end | ||
|
||
test "login should redirect to create user if non-existant user" do | ||
get :login, nil, {:cas_user => "nonexistantuser"} | ||
assert_redirected_to :new_user | ||
end | ||
end |