summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/v1/sessions_controller.rb2
-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
-rw-r--r--app/views/layouts/_header.html.haml2
-rw-r--r--app/views/layouts/_masthead.html.haml2
-rw-r--r--app/views/layouts/application.html.haml3
9 files changed, 36 insertions, 4 deletions
diff --git a/app/controllers/v1/sessions_controller.rb b/app/controllers/v1/sessions_controller.rb
index eae3a1e..d88fcdc 100644
--- a/app/controllers/v1/sessions_controller.rb
+++ b/app/controllers/v1/sessions_controller.rb
@@ -38,7 +38,7 @@ module V1
def login_response
handshake = session.delete(:handshake) || {}
- handshake.to_hash.merge(:id => current_user.id, :token => @token.id)
+ handshake.to_hash.merge(:id => current_user.id, :token => @token.to_s)
end
end
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
diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml
index 157f1df..a1dd47a 100644
--- a/app/views/layouts/_header.html.haml
+++ b/app/views/layouts/_header.html.haml
@@ -8,5 +8,5 @@
%li
= link_to t(:logout), logout_path, :method => :delete
- if @user && @show_navigation
- .user_heading
+ .lead
= @user.email_address
diff --git a/app/views/layouts/_masthead.html.haml b/app/views/layouts/_masthead.html.haml
index 35225a1..fde5915 100644
--- a/app/views/layouts/_masthead.html.haml
+++ b/app/views/layouts/_masthead.html.haml
@@ -2,5 +2,3 @@
.title
%span.sitename
%a{:href => home_path}= APP_CONFIG[:domain]
- - if @show_navigation
- = t(:user_control_panel) \ No newline at end of file
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 1cd4ec3..d213fe1 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -14,6 +14,9 @@
= render 'layouts/masthead'
#main
.container-fluid
+ - if @show_navigation
+ .row-fluid
+ %h1= t(:user_control_panel)
- if logged_in?
.row-fluid
.span12