summaryrefslogtreecommitdiff
path: root/users/app/models/local_email.rb
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/models/local_email.rb')
-rw-r--r--users/app/models/local_email.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb
new file mode 100644
index 0000000..7cca4f4
--- /dev/null
+++ b/users/app/models/local_email.rb
@@ -0,0 +1,15 @@
+class LocalEmail < Email
+
+ validate :unique_on_server
+
+ def to_partial_path
+ "emails/email"
+ end
+
+ def unique_on_server
+ has_email = User.find_by_email_or_alias(email)
+ if has_email && has_email != self.base_doc
+ errors.add(:email, "has already been taken")
+ end
+ end
+end