Skip to content

Commit

Permalink
Merge pull request #176 from mlibrary/devise_email
Browse files Browse the repository at this point in the history
Devise email
  • Loading branch information
grosscol committed Feb 29, 2016
2 parents b432c80 + d4fb7a1 commit 14246ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class User < ActiveRecord::Base
include Sufia::User
include Sufia::UserUsageStats

before_validation :generate_password, :on => :create

def generate_password
self.password = SecureRandom.urlsafe_base64(12)
end

# Use the http header as auth. This app will be behind a reverse proxy
# that will take care of the authentication.
Devise.add_module(:http_header_authenticatable,
Expand Down
4 changes: 2 additions & 2 deletions app/views/contact_form/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<% if user_signed_in? %>
<% nm = '' %>
<% em = current_user.name + "@umich.edu" %>
<% em = current_user.user_key %>
<% else %>
<% nm = '' %>
<% em = '' %>
Expand Down Expand Up @@ -41,4 +41,4 @@
<% end %>

</div>
</div>
</div>
5 changes: 3 additions & 2 deletions lib/devise/behaviors/http_header_authenticatable_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ def valid_user?(headers)

protected

# Remote user is coming back from cosign as uniquename.
# Append @umich.edu to this value to satisfy user model validations
def remote_user(headers)
return headers['HTTP_X_REMOTE_USER'] if headers['HTTP_X_REMOTE_USER']
return headers['HTTP_REMOTE_USER'] if headers['HTTP_REMOTE_USER'] && Rails.env.development?
return "#{headers['HTTP_X_REMOTE_USER']}@umich.edu" if headers['HTTP_X_REMOTE_USER']
return nil
end

Expand Down

0 comments on commit 14246ff

Please sign in to comment.