summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2014-05-14 08:41:13 +0200
committerazul <azul@riseup.net>2014-05-14 08:41:13 +0200
commitc85028fba2a25f22b375b8714c2e1999c35f8e82 (patch)
treee9c6a5c25e0bb7acaddae1f34a9fd0de886bbeb8 /app/models
parent4843db127a5d5d038f227d9ffe5f0b83d95fd9f6 (diff)
parent3278e474a32ef4926b1dab0d97ca4df1c59aa2a0 (diff)
Merge pull request #157 from azul/bugfix/5664-stop-email-autofill
Bugfix/5664 stop email autofill
Diffstat (limited to 'app/models')
-rw-r--r--app/models/anonymous_user.rb4
-rw-r--r--app/models/identity.rb6
-rw-r--r--app/models/service_level.rb8
-rw-r--r--app/models/token.rb4
-rw-r--r--app/models/user.rb9
5 files changed, 31 insertions, 0 deletions
diff --git a/app/models/anonymous_user.rb b/app/models/anonymous_user.rb
index 360a577..87239eb 100644
--- a/app/models/anonymous_user.rb
+++ b/app/models/anonymous_user.rb
@@ -13,6 +13,10 @@ class AnonymousUser < Object
nil
end
+ def email
+ nil
+ end
+
def email_address
nil
end
diff --git a/app/models/identity.rb b/app/models/identity.rb
index 9b97b51..ad8c01e 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -70,6 +70,12 @@ class Identity < CouchRest::Model::Base
end
end
+ def self.destroy_all_for(user)
+ Identity.by_user_id.key(user.id).each do |identity|
+ identity.destroy
+ end
+ end
+
def self.destroy_all_disabled
Identity.disabled.each do |identity|
identity.destroy
diff --git a/app/models/service_level.rb b/app/models/service_level.rb
index 5dd8838..a8df55b 100644
--- a/app/models/service_level.rb
+++ b/app/models/service_level.rb
@@ -24,6 +24,14 @@ class ServiceLevel
end
end
+ def provides?(service)
+ services.include? service
+ end
+
+ def services
+ config_hash[:services] || []
+ end
+
protected
def limited_cert?
diff --git a/app/models/token.rb b/app/models/token.rb
index 4856c31..e759ee3 100644
--- a/app/models/token.rb
+++ b/app/models/token.rb
@@ -30,6 +30,10 @@ class Token < CouchRest::Model::Base
end
end
+ def to_s
+ id
+ end
+
def authenticate
if expired?
destroy
diff --git a/app/models/user.rb b/app/models/user.rb
index c297ac8..6678de6 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -61,6 +61,15 @@ class User < CouchRest::Model::Base
login
end
+ # use this if you want to get a working email address only.
+ def email
+ if effective_service_level.provides?('email')
+ email_address
+ end
+ end
+
+ # use this if you want the email address associated with a
+ # user no matter if the user actually has a local email account
def email_address
LocalEmail.new(login)
end