summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/users_controller.rb2
-rw-r--r--users/app/models/email.rb5
-rw-r--r--users/app/models/user.rb7
3 files changed, 14 insertions, 0 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 5055f4e..811e8e5 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -33,6 +33,8 @@ class UsersController < ApplicationController
@user.attributes = params[:user]
if @user.changed? and @user.save
flash[:notice] = t(:user_updated_successfully)
+ else
+ flash[:error] = @user.errors.full_messages
end
respond_with @user, :location => edit_user_path(@user)
end
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 0988d9f..7c88c51 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -3,6 +3,11 @@ class Email
property :email, String
+ validates :email_forward,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
+ timestamps!
+
def to_s
email
end
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index fcb211e..a41554d 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -26,6 +26,13 @@ class User < CouchRest::Model::Base
:confirmation => true,
:format => { :with => /.{8}.*/, :message => "needs to be at least 8 characters long" }
+ # TODO: write a proper email validator to be used in the different places
+ validates :email,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
+ validates :email_forward,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
timestamps!
design do