aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-05 19:37:10 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-11 20:03:02 +0200
commit12102baa7d1c875c6ffd1d2941085c9679bd435d (patch)
tree5bbe831e98f53aed19e669950fcf486fe50f717d
parentAlternative login with openID (diff)
downloadrecruiting-webapp-12102baa7d1c875c6ffd1d2941085c9679bd435d.tar.gz
recruiting-webapp-12102baa7d1c875c6ffd1d2941085c9679bd435d.tar.bz2
recruiting-webapp-12102baa7d1c875c6ffd1d2941085c9679bd435d.zip
If user is invalid only thing [s]he can do is editing his/her account.
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/controllers/users_controller.rb1
-rw-r--r--app/models/guest.rb1
-rw-r--r--app/views/users/edit.dryml9
-rw-r--r--features/openid.feature12
5 files changed, 33 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6635a3f..d1623af 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -5,6 +5,16 @@ class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
+ append_before_filter :only_valid_users
+
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
+
+ protected
+ def only_valid_users
+ unless current_user.valid?
+ flash[:notice] = "You user account is invalid, please fix problems before you continue."
+ redirect_to edit_user_path(current_user)
+ end
+ end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 18642a0..d4d7644 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -3,6 +3,7 @@ class UsersController < ApplicationController
hobo_user_controller
openid_login:openid_opts => { :model => User }
+ skip_before_filter :only_valid_users, :only => [:edit, :update]
auto_actions :all, :except => [ :index, :new, :create ]
index_action :ready_recruits
index_action :mentorless_recruits
diff --git a/app/models/guest.rb b/app/models/guest.rb
index 904dfe1..2e6a677 100644
--- a/app/models/guest.rb
+++ b/app/models/guest.rb
@@ -10,4 +10,5 @@ class Guest < Hobo::Guest
def questions_to_approve; []; end
def role; Role.new(:guest); end
def token; nil; end
+ def valid?; true; end
end
diff --git a/app/views/users/edit.dryml b/app/views/users/edit.dryml
new file mode 100644
index 0000000..f974b53
--- /dev/null
+++ b/app/views/users/edit.dryml
@@ -0,0 +1,9 @@
+<edit-page if="&current_user.valid?" />
+<else>
+ <edit-page>
+ <body:>
+ <h1>Please set data for your account.</h1>
+ <form/>
+ </body:>
+ </edit-page>
+</else>
diff --git a/features/openid.feature b/features/openid.feature
index 23bbeb1..8d09795 100644
--- a/features/openid.feature
+++ b/features/openid.feature
@@ -22,3 +22,15 @@ Feature: OpenID
And I fill in "login" with "https://example.com/id"
And I press "Log in"
Then I should see "Welcome, Example name"
+
+ Scenario: User with invalid accounts can only edit their accounts
+ Given I am on the homepage
+ And openid is always succesfull
+ When I follow "Sign up"
+ And I follow "sign up using OpenID"
+ And I fill in "login" with "https://example.com/id"
+ And I press "Log in"
+
+ When I am on the homepage
+ Then I should be on edit "" user page
+ And I should see "Please set data for your account"