diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/keys_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/pages_controller.rb | 2 | ||||
-rw-r--r-- | app/models/account.rb | 5 | ||||
-rw-r--r-- | app/models/user.rb | 8 |
4 files changed, 15 insertions, 7 deletions
diff --git a/app/controllers/keys_controller.rb b/app/controllers/keys_controller.rb index fb28901..dbb5d96 100644 --- a/app/controllers/keys_controller.rb +++ b/app/controllers/keys_controller.rb @@ -3,15 +3,16 @@ class KeysController < ApplicationController # # Render the user's key as plain text, without a layout. # - # We will show blank page if user doesn't have key (which shouldn't generally occur) - # and a 404 error if user doesn't exist + # 404 error if user doesn't exist + # + # blank result if user doesn't have key (which shouldn't generally occur) # def show user = User.find_by_login(params[:login]) if user render text: user.public_key, content_type: 'text/text' else - raise ActionController::RoutingError.new('Not Found') + head 404 end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b9c601a..4508450 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,6 +9,8 @@ class PagesController < ApplicationController def show @show_navigation = false render page_name + rescue ActionView::MissingTemplate + raise ActionController::RoutingError.new('Not Found') end private diff --git a/app/models/account.rb b/app/models/account.rb index d722caa..3283bcc 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -47,7 +47,7 @@ class Account user_invite_code.save end end - rescue StandardError => ex + rescue VALIDATION_FAILED => ex user.errors.add(:base, ex.to_s) if user ensure if creation_problem?(user, identity) @@ -62,6 +62,9 @@ class Account update_login(attrs[:login]) @user.update_attributes attrs.slice(:password_verifier, :password_salt) end + if attrs[:recovery_code_verifier].present? + @user.update_attributes attrs.slice(:recovery_code_verifier, :recovery_code_salt) + end # TODO: move into identity controller key = update_pgp_key(attrs[:public_key]) @user.errors.set :public_key, key.errors.full_messages diff --git a/app/models/user.rb b/app/models/user.rb index 9cebbca..f8869cd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,6 +8,8 @@ class User < CouchRest::Model::Base property :login, String, :accessible => true property :password_verifier, String, :accessible => true property :password_salt, String, :accessible => true + property :recovery_code_verifier, String, :accessible => true + property :recovery_code_salt, String, :accessible => true property :contact_email, String, :accessible => true property :contact_email_key, String, :accessible => true property :invite_code, String, :accessible => true @@ -33,8 +35,8 @@ class User < CouchRest::Model::Base validate :identity_is_valid - validates :password_salt, :password_verifier, - :format => { :with => /\A[\dA-Fa-f]+\z/, :message => "Only hex numbers allowed" } + validates :password_salt, :password_verifier, :recovery_code_verifier, :recovery_code_salt, + :format => { :with => /\A[\h]*\z/, :message => "Only hex numbers allowed" } validates :password, :presence => true, :confirmation => true, @@ -230,7 +232,7 @@ class User < CouchRest::Model::Base def identity_is_valid return if identity.valid? identity.errors.each do |attribute, error| - self.errors.add(:login, error) + errors.add(:login, error) unless errors[:login].include? error end end |