Convert OpenID authentication to generic third party authentication
This commit is contained in:
parent
eaf4b32a7f
commit
e434cb154c
14 changed files with 254 additions and 175 deletions
|
@ -1,6 +1,7 @@
|
||||||
//= require leaflet.locate
|
//= require leaflet.locate
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
if ($("#map").length) {
|
||||||
var map = L.map("map", {
|
var map = L.map("map", {
|
||||||
attributionControl: false,
|
attributionControl: false,
|
||||||
zoomControl: false
|
zoomControl: false
|
||||||
|
@ -56,4 +57,39 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAuthUID() {
|
||||||
|
var provider = $("select#user_auth_provider").val();
|
||||||
|
|
||||||
|
if (provider === "openid") {
|
||||||
|
$("input#user_auth_uid").show().prop("disabled", false);
|
||||||
|
} else {
|
||||||
|
$("input#user_auth_uid").hide().prop("disabled", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAuthUID();
|
||||||
|
|
||||||
|
$("select#user_auth_provider").on("change", updateAuthUID);
|
||||||
|
|
||||||
|
function enableAuth() {
|
||||||
|
$("#auth_prompt").hide();
|
||||||
|
$("#auth_field").show();
|
||||||
|
$("#user_auth_uid").prop("disabled", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableAuth() {
|
||||||
|
$("#auth_prompt").show();
|
||||||
|
$("#auth_field").hide();
|
||||||
|
$("#user_auth_uid").prop("disabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#auth_enable").click(enableAuth);
|
||||||
|
|
||||||
|
if ($("select#user_auth_provider").val() === "") {
|
||||||
|
disableAuth();
|
||||||
|
} else {
|
||||||
|
enableAuth();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1681,11 +1681,11 @@ tr.turn:hover {
|
||||||
|
|
||||||
/* Rules for the log in page */
|
/* Rules for the log in page */
|
||||||
|
|
||||||
#login_openid_buttons {
|
#login_auth_buttons {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login_openid_buttons li {
|
#login_auth_buttons li {
|
||||||
float: left;
|
float: left;
|
||||||
padding: $lineheight/4 $lineheight/2;
|
padding: $lineheight/4 $lineheight/2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,11 @@ class UserController < ApplicationController
|
||||||
@user.languages = http_accept_language.user_preferred_languages
|
@user.languages = http_accept_language.user_preferred_languages
|
||||||
@user.terms_agreed = Time.now.getutc
|
@user.terms_agreed = Time.now.getutc
|
||||||
@user.terms_seen = true
|
@user.terms_seen = true
|
||||||
@user.openid_url = nil if @user.openid_url && @user.openid_url.empty?
|
|
||||||
|
if @user.auth_uid.nil? || @user.auth_uid.empty?
|
||||||
|
@user.auth_provider = nil
|
||||||
|
@user.auth_uid = nil
|
||||||
|
end
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
flash[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
|
flash[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
|
||||||
|
@ -119,17 +123,13 @@ class UserController < ApplicationController
|
||||||
@tokens = @user.oauth_tokens.authorized
|
@tokens = @user.oauth_tokens.authorized
|
||||||
|
|
||||||
if params[:user] && params[:user][:display_name] && params[:user][:description]
|
if params[:user] && params[:user][:display_name] && params[:user][:description]
|
||||||
if params[:user][:openid_url] &&
|
if params[:user][:auth_provider].blank? ||
|
||||||
params[:user][:openid_url].length > 0 &&
|
(params[:user][:auth_provider] == @user.auth_provider &&
|
||||||
params[:user][:openid_url] != @user.openid_url
|
params[:user][:auth_uid] == @user.auth_uid)
|
||||||
# If the OpenID has changed, we want to check that it is a
|
|
||||||
# valid OpenID and one the user has control over before saving
|
|
||||||
# it as a password equivalent for the user.
|
|
||||||
session[:new_user_settings] = params
|
|
||||||
openid_url = openid_expand_url(params[:user][:openid_url])
|
|
||||||
redirect_to auth_path(:provider => "openid", :openid_url => openid_url, :origin => request.path)
|
|
||||||
else
|
|
||||||
update_user(@user, params)
|
update_user(@user, params)
|
||||||
|
else
|
||||||
|
session[:new_user_settings] = params
|
||||||
|
redirect_to auth_url(params[:user][:auth_provider], params[:user][:auth_uid])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,13 +206,14 @@ class UserController < ApplicationController
|
||||||
else
|
else
|
||||||
redirect_to :controller => "site", :action => "index"
|
redirect_to :controller => "site", :action => "index"
|
||||||
end
|
end
|
||||||
elsif params.key?(:openid)
|
elsif params.key?(:auth_provider) && params.key?(:auth_uid)
|
||||||
@user = User.new(:email => params[:email],
|
@user = User.new(:email => params[:email],
|
||||||
:email_confirmation => params[:email],
|
:email_confirmation => params[:email],
|
||||||
:display_name => params[:nickname],
|
:display_name => params[:nickname],
|
||||||
:openid_url => params[:openid])
|
:auth_provider => params[:auth_provider],
|
||||||
|
:auth_uid => params[:auth_uid])
|
||||||
|
|
||||||
flash.now[:notice] = t "user.new.openid association"
|
flash.now[:notice] = t "user.new.auth association"
|
||||||
else
|
else
|
||||||
check_signup_allowed
|
check_signup_allowed
|
||||||
end
|
end
|
||||||
|
@ -226,9 +227,9 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
@user.status = "pending"
|
@user.status = "pending"
|
||||||
|
|
||||||
if @user.openid_url.present? && @user.pass_crypt.empty?
|
if @user.auth_provider.present? && @user.auth_uid.present? && @user.pass_crypt.empty?
|
||||||
# We are creating an account with OpenID and no password
|
# We are creating an account with external authentication and
|
||||||
# was specified so create a random one
|
# no password was specified so create a random one
|
||||||
@user.pass_crypt = SecureRandom.base64(16)
|
@user.pass_crypt = SecureRandom.base64(16)
|
||||||
@user.pass_crypt_confirmation = @user.pass_crypt
|
@user.pass_crypt_confirmation = @user.pass_crypt
|
||||||
end
|
end
|
||||||
|
@ -236,11 +237,10 @@ class UserController < ApplicationController
|
||||||
if @user.invalid?
|
if @user.invalid?
|
||||||
# Something is wrong with a new user, so rerender the form
|
# Something is wrong with a new user, so rerender the form
|
||||||
render :action => "new"
|
render :action => "new"
|
||||||
elsif @user.openid_url.present?
|
elsif @user.auth_provider.present? && @user.auth_uid.present?
|
||||||
# Verify OpenID before moving on
|
# Verify external authenticator before moving on
|
||||||
session[:new_user] = @user
|
session[:new_user] = @user
|
||||||
openid_url = openid_expand_url(@user.openid_url)
|
redirect_to auth_url(@user.auth_provider, @user.auth_uid)
|
||||||
redirect_to auth_path(:provider => "openid", :openid_url => openid_url, :origin => request.path)
|
|
||||||
else
|
else
|
||||||
# Save the user record
|
# Save the user record
|
||||||
session[:new_user] = @user
|
session[:new_user] = @user
|
||||||
|
@ -255,8 +255,7 @@ class UserController < ApplicationController
|
||||||
|
|
||||||
if params[:openid_url].present?
|
if params[:openid_url].present?
|
||||||
session[:remember_me] ||= params[:remember_me_openid]
|
session[:remember_me] ||= params[:remember_me_openid]
|
||||||
openid_url = openid_expand_url(params[:openid_url])
|
redirect_to auth_url("openid", params[:openid_url])
|
||||||
redirect_to auth_path(:provider => "openid", :openid_url => openid_url, :origin => request.path)
|
|
||||||
else
|
else
|
||||||
session[:remember_me] ||= params[:remember_me]
|
session[:remember_me] ||= params[:remember_me]
|
||||||
password_authentication(params[:username], params[:password])
|
password_authentication(params[:username], params[:password])
|
||||||
|
@ -482,11 +481,20 @@ class UserController < ApplicationController
|
||||||
def auth_success
|
def auth_success
|
||||||
auth_info = env["omniauth.auth"]
|
auth_info = env["omniauth.auth"]
|
||||||
|
|
||||||
openid_url = auth_info[:uid]
|
provider = auth_info[:provider]
|
||||||
|
uid = auth_info[:uid]
|
||||||
name = auth_info[:info][:name]
|
name = auth_info[:info][:name]
|
||||||
email = auth_info[:info][:email]
|
email = auth_info[:info][:email]
|
||||||
|
|
||||||
if user = User.find_by_openid_url(openid_url)
|
case provider
|
||||||
|
when "openid"
|
||||||
|
email_verified = uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) ||
|
||||||
|
uid.match(%r{https://me.yahoo.com/(.*)})
|
||||||
|
else
|
||||||
|
email_verified = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if user = User.find_by_auth_provider_and_auth_uid(provider, uid)
|
||||||
case user.status
|
case user.status
|
||||||
when "pending" then
|
when "pending" then
|
||||||
unconfirmed_login(user)
|
unconfirmed_login(user)
|
||||||
|
@ -498,21 +506,24 @@ class UserController < ApplicationController
|
||||||
failed_login t("user.login.auth failure")
|
failed_login t("user.login.auth failure")
|
||||||
end
|
end
|
||||||
elsif settings = session.delete(:new_user_settings)
|
elsif settings = session.delete(:new_user_settings)
|
||||||
@user.openid_url = openid_url
|
@user.auth_provider = provider
|
||||||
|
@user.auth_uid = uid
|
||||||
|
|
||||||
update_user(@user, settings)
|
update_user(@user, settings)
|
||||||
|
|
||||||
redirect_to :action => "account", :display_name => @user.display_name
|
redirect_to :action => "account", :display_name => @user.display_name
|
||||||
elsif session[:new_user]
|
elsif session[:new_user]
|
||||||
session[:new_user].openid_url = openid_url
|
session[:new_user].auth_provider = provider
|
||||||
|
session[:new_user].auth_uid = uid
|
||||||
|
|
||||||
if email == session[:new_user].email && openid_email_verified(email)
|
if email_verified && email == session[:new_user].email
|
||||||
session[:new_user].status = "active"
|
session[:new_user].status = "active"
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to :action => "terms"
|
redirect_to :action => "terms"
|
||||||
else
|
else
|
||||||
redirect_to :action => "new", :nickname => name, :email => email, :openid => openid_url
|
redirect_to :action => "new", :nickname => name, :email => email,
|
||||||
|
:auth_provider => provider, :auth_uid => uid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -539,6 +550,16 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# return the URL to use for authentication
|
||||||
|
def auth_url(provider, uid)
|
||||||
|
if provider == "openid"
|
||||||
|
auth_path(:provider => "openid", :openid_url => openid_expand_url(uid), :origin => request.path)
|
||||||
|
else
|
||||||
|
auth_path(:provider => provider, :origin => request.path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# special case some common OpenID providers by applying heuristics to
|
# special case some common OpenID providers by applying heuristics to
|
||||||
# try and come up with the correct URL based on what the user entered
|
# try and come up with the correct URL based on what the user entered
|
||||||
|
@ -556,14 +577,6 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# check if we trust an OpenID provider to return a verified
|
|
||||||
# email, so that we can skpi verifying it ourselves
|
|
||||||
def openid_email_verified(openid_url)
|
|
||||||
openid_url.match(%r{https://www.google.com/accounts/o8/id?(.*)}) ||
|
|
||||||
openid_url.match(%r{https://me.yahoo.com/(.*)})
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# process a successful login
|
# process a successful login
|
||||||
def successful_login(user)
|
def successful_login(user)
|
||||||
|
@ -649,7 +662,11 @@ class UserController < ApplicationController
|
||||||
user.preferred_editor = params[:user][:preferred_editor]
|
user.preferred_editor = params[:user][:preferred_editor]
|
||||||
end
|
end
|
||||||
|
|
||||||
user.openid_url = nil if params[:user][:openid_url].blank?
|
if params[:user][:auth_provider].nil? || params[:user][:auth_provider].blank? ||
|
||||||
|
params[:user][:auth_uid].nil? || params[:user][:auth_uid].blank?
|
||||||
|
user.auth_provider = nil
|
||||||
|
user.auth_uid = nil
|
||||||
|
end
|
||||||
|
|
||||||
if user.save
|
if user.save
|
||||||
set_locale
|
set_locale
|
||||||
|
@ -728,7 +745,9 @@ class UserController < ApplicationController
|
||||||
##
|
##
|
||||||
# return permitted user parameters
|
# return permitted user parameters
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:email, :email_confirmation, :display_name, :openid_url, :pass_crypt, :pass_crypt_confirmation)
|
params.require(:user).permit(:email, :email_confirmation, :display_name,
|
||||||
|
:auth_provider, :auth_uid,
|
||||||
|
:pass_crypt, :pass_crypt_confirmation)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -42,18 +42,18 @@ module UserHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# OpenID support
|
# External authentication support
|
||||||
|
|
||||||
def openid_logo
|
def openid_logo
|
||||||
image_tag "openid_small.png", :alt => t("user.login.openid_logo_alt"), :class => "openid_logo"
|
image_tag "openid_small.png", :alt => t("user.login.openid_logo_alt"), :class => "openid_logo"
|
||||||
end
|
end
|
||||||
|
|
||||||
def openid_button(name, url)
|
def auth_button(name, provider, options)
|
||||||
link_to(
|
link_to(
|
||||||
image_tag("#{name}.png", :alt => t("user.login.openid_providers.#{name}.alt")),
|
image_tag("#{name}.png", :alt => t("user.login.auth_providers.#{name}.alt")),
|
||||||
auth_path(:provider => "openid", :openid_url => url),
|
auth_path(options.merge(:provider => provider)),
|
||||||
:class => "openid_button",
|
:class => "auth_button",
|
||||||
:title => t("user.login.openid_providers.#{name}.title")
|
:title => t("user.login.auth_providers.#{name}.title")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ class User < ActiveRecord::Base
|
||||||
validates_confirmation_of :pass_crypt # , :message => ' must match the confirmation password'
|
validates_confirmation_of :pass_crypt # , :message => ' must match the confirmation password'
|
||||||
validates_uniqueness_of :display_name, :allow_nil => true, :case_sensitive => false, :if => proc { |u| u.display_name_changed? }
|
validates_uniqueness_of :display_name, :allow_nil => true, :case_sensitive => false, :if => proc { |u| u.display_name_changed? }
|
||||||
validates_uniqueness_of :email, :case_sensitive => false, :if => proc { |u| u.email_changed? }
|
validates_uniqueness_of :email, :case_sensitive => false, :if => proc { |u| u.email_changed? }
|
||||||
validates_uniqueness_of :openid_url, :allow_nil => true
|
|
||||||
validates_length_of :pass_crypt, :within => 8..255
|
validates_length_of :pass_crypt, :within => 8..255
|
||||||
validates_length_of :display_name, :within => 3..255, :allow_nil => true
|
validates_length_of :display_name, :within => 3..255, :allow_nil => true
|
||||||
validates_email_format_of :email, :if => proc { |u| u.email_changed? }
|
validates_email_format_of :email, :if => proc { |u| u.email_changed? }
|
||||||
|
@ -199,7 +198,8 @@ class User < ActiveRecord::Base
|
||||||
self.image = nil
|
self.image = nil
|
||||||
self.email_valid = false
|
self.email_valid = false
|
||||||
self.new_email = nil
|
self.new_email = nil
|
||||||
self.openid_url = nil
|
self.auth_provider = nil
|
||||||
|
self.auth_uid = nil
|
||||||
self.status = "deleted"
|
self.status = "deleted"
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
<% content_for :head do %>
|
||||||
|
<%= javascript_include_tag "user" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% content_for :heading do %>
|
<% content_for :heading do %>
|
||||||
<h1><%= t 'user.account.my settings' %></h1>
|
<h1><%= t 'user.account.my settings' %></h1>
|
||||||
<ul class='secondary-actions clearfix'>
|
<ul class='secondary-actions clearfix'>
|
||||||
|
@ -43,8 +47,9 @@
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label class="standard-label"><%= t 'user.account.openid.openid' %></label>
|
<label class="standard-label"><%= t 'user.account.external auth' %></label>
|
||||||
<%= f.text_field :openid_url, {:id => "openid_url", :class => "openid_url"} %>
|
<%= f.select :auth_provider, { "None" => "", "OpenID" => "openid" } %>
|
||||||
|
<%= f.text_field :auth_uid %>
|
||||||
<span class="form-help deemphasize">(<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>)</span>
|
<span class="form-help deemphasize">(<a href="<%= t 'user.account.openid.link' %>" target="_new"><%= t 'user.account.openid.link text' %></a>)</span>
|
||||||
</diV>
|
</diV>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -161,9 +166,6 @@
|
||||||
<input type="checkbox" name="updatehome" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" />
|
<input type="checkbox" name="updatehome" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" />
|
||||||
<label class="standard-label" for="updatehome"><%= t 'user.account.update home location on click' %></label>
|
<label class="standard-label" for="updatehome"><%= t 'user.account.update home location on click' %></label>
|
||||||
</div>
|
</div>
|
||||||
<% content_for :head do %>
|
|
||||||
<%= javascript_include_tag "user" %>
|
|
||||||
<% end %>
|
|
||||||
<%= content_tag "div", "", :id => "map", :class => "content_map settings_map set_location" %>
|
<%= content_tag "div", "", :id => "map", :class => "content_map settings_map set_location" %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,14 @@
|
||||||
|
|
||||||
<fieldset class='form-divider'>
|
<fieldset class='form-divider'>
|
||||||
|
|
||||||
<p class='standard-label'><%= t 'user.login.with openid' %></p>
|
<p class='standard-label'><%= t 'user.login.with external' %></p>
|
||||||
|
|
||||||
<ul class='clearfix' id="login_openid_buttons">
|
<ul class='clearfix' id="login_auth_buttons">
|
||||||
<li><%= link_to image_tag("openid.png", :alt => t("user.login.openid_providers.openid.title")), "#", :id => "openid_open_url", :title => t("user.login.openid_providers.openid.title") %></li>
|
<li><%= link_to image_tag("openid.png", :alt => t("user.login.auth_providers.openid.title")), "#", :id => "openid_open_url", :title => t("user.login.auth_providers.openid.title") %></li>
|
||||||
<li><%= openid_button "google", "https://www.google.com/accounts/o8/id" %></li>
|
<li><%= auth_button "google", "openid", :openid_url => "https://www.google.com/accounts/o8/id" %></li>
|
||||||
<li><%= openid_button "yahoo", "yahoo.com" %></li>
|
<li><%= auth_button "yahoo", "openid", :openid_url => "yahoo.com" %></li>
|
||||||
<li><%= openid_button "wordpress", "wordpress.com" %></li>
|
<li><%= auth_button "wordpress", "openid", :openid_url => "wordpress.com" %></li>
|
||||||
<li><%= openid_button "aol", "aol.com" %></li>
|
<li><%= auth_button "aol", "openid", :openid_url => "aol.com" %></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id='login_openid_url' class='form-row'>
|
<div id='login_openid_url' class='form-row'>
|
||||||
|
@ -78,7 +78,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$("#openid_open_url").click(function() {
|
$("#openid_open_url").click(function() {
|
||||||
$("#openid_url").val("http://");
|
$("#openid_url").val("http://");
|
||||||
$("#login_openid_buttons").hide();
|
$("#login_auth_buttons").hide();
|
||||||
$("#login_openid_url").show();
|
$("#login_openid_url").show();
|
||||||
$("#login_openid_submit").show();
|
$("#login_openid_submit").show();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
<% content_for :head do %>
|
||||||
|
<%= javascript_include_tag "user" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% content_for :heading do %>
|
<% content_for :heading do %>
|
||||||
<h1><%= t 'user.new.title' %></h1>
|
<h1><%= t 'user.new.title' %></h1>
|
||||||
<div class='header-illustration new-user-main'></div>
|
<div class='header-illustration new-user-main'></div>
|
||||||
|
@ -36,15 +40,16 @@
|
||||||
<span class="form-help deemphasize"><%= t 'user.new.display name description' %></span>
|
<span class="form-help deemphasize"><%= t 'user.new.display name description' %></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="form-divider" id="openid_field">
|
<fieldset class="form-divider" id="auth_field">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="openid_url" class="standard-label">
|
<label for="openid_url" class="standard-label">
|
||||||
<%= raw t 'user.new.openid', :logo => openid_logo %>
|
<%= raw t 'user.new.external auth' %>
|
||||||
</label>
|
</label>
|
||||||
<%= text_field(:user, :openid_url, { :id => "openid_url", :tabindex => 4, :class => "openid_url" }) %>
|
<%= select(:user, :auth_provider, { "None" => "", "OpenID" => "openid" }, { :default => "", :tabindex => 4 }) %>
|
||||||
<%= error_message_on(:user, :openid_url) %>
|
<%= text_field(:user, :auth_uid, { :tabindex => 5 }) %>
|
||||||
|
<%= error_message_on(:user, :auth_uid) %>
|
||||||
</div>
|
</div>
|
||||||
<span class="form-help deemphasize"><%= t 'user.new.openid no password' %></span>
|
<span class="form-help deemphasize"><%= t 'user.new.auth no password' %></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -52,52 +57,26 @@
|
||||||
<label for='user[pass_crypt]' class="standard-label">
|
<label for='user[pass_crypt]' class="standard-label">
|
||||||
<%= t 'user.new.password' %>
|
<%= t 'user.new.password' %>
|
||||||
</label>
|
</label>
|
||||||
<%= password_field(:user, :pass_crypt, {:tabindex => 5 }) %>
|
<%= password_field(:user, :pass_crypt, { :tabindex => 6 }) %>
|
||||||
<%= error_message_on(:user, :pass_crypt) %>
|
<%= error_message_on(:user, :pass_crypt) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label class="standard-label">
|
<label class="standard-label">
|
||||||
<%= t 'user.new.confirm password' %>
|
<%= t 'user.new.confirm password' %>
|
||||||
</label>
|
</label>
|
||||||
<%= password_field(:user, :pass_crypt_confirmation, { :tabindex => 6 }) %>
|
<%= password_field(:user, :pass_crypt_confirmation, { :tabindex => 7 }) %>
|
||||||
<%= error_message_on(:user, :pass_crypt_confirmation) %>
|
<%= error_message_on(:user, :pass_crypt_confirmation) %>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<div id="openid_prompt" class="form-row">
|
<div id="auth_prompt" class="form-row">
|
||||||
<%= link_to raw(t("user.new.use openid", :logo => openid_logo)), "#", :id => "openid_enable" %>
|
<%= link_to raw(t("user.new.use external auth")), "#", :id => "auth_enable" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= submit_tag t('user.new.continue'), :tabindex => 6 %>
|
<%= submit_tag t('user.new.continue'), :tabindex => 8 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class='aside col6 deemphasize inner22'>
|
<div class='aside col6 deemphasize inner22'>
|
||||||
<h4><%= t 'user.new.about.header' %></h4>
|
<h4><%= t 'user.new.about.header' %></h4>
|
||||||
<%= t 'user.new.about.html' %>
|
<%= t 'user.new.about.html' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function enableOpenID()
|
|
||||||
{
|
|
||||||
$("#openid_prompt").hide();
|
|
||||||
$("#openid_field").show();
|
|
||||||
$("#openid_url").prop("disabled", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function disableOpenID()
|
|
||||||
{
|
|
||||||
$("#openid_prompt").show();
|
|
||||||
$("#openid_field").hide();
|
|
||||||
$("#openid_url").prop("disabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
$("#openid_enable").click(enableOpenID);
|
|
||||||
|
|
||||||
<% if params[:openid] or (@user and @user.openid_url.present?) -%>
|
|
||||||
enableOpenID();
|
|
||||||
<% else -%>
|
|
||||||
disableOpenID();
|
|
||||||
<% end -%>
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -1681,7 +1681,7 @@ en:
|
||||||
login_button: "Login"
|
login_button: "Login"
|
||||||
register now: Register now
|
register now: Register now
|
||||||
with username: "Already have an OpenStreetMap account? Please login with your username and password:"
|
with username: "Already have an OpenStreetMap account? Please login with your username and password:"
|
||||||
with openid: "Alternatively, use OpenID to login:"
|
with external: "Alternatively, use a third party to login:"
|
||||||
new to osm: New to OpenStreetMap?
|
new to osm: New to OpenStreetMap?
|
||||||
to make changes: To make changes to the OpenStreetMap data, you must have an account.
|
to make changes: To make changes to the OpenStreetMap data, you must have an account.
|
||||||
create account minute: Create an account. It only takes a minute.
|
create account minute: Create an account. It only takes a minute.
|
||||||
|
@ -1690,7 +1690,7 @@ en:
|
||||||
account is suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact the <a href="%{webmaster}">webmaster</a> if you wish to discuss this.
|
account is suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact the <a href="%{webmaster}">webmaster</a> if you wish to discuss this.
|
||||||
auth failure: "Sorry, could not log in with those details."
|
auth failure: "Sorry, could not log in with those details."
|
||||||
openid_logo_alt: "Log in with an OpenID"
|
openid_logo_alt: "Log in with an OpenID"
|
||||||
openid_providers:
|
auth_providers:
|
||||||
openid:
|
openid:
|
||||||
title: Login with OpenID
|
title: Login with OpenID
|
||||||
alt: Login with an OpenID URL
|
alt: Login with an OpenID URL
|
||||||
|
@ -1742,19 +1742,19 @@ en:
|
||||||
not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
|
not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
|
||||||
display name: "Display Name:"
|
display name: "Display Name:"
|
||||||
display name description: "Your publicly displayed username. You can change this later in the preferences."
|
display name description: "Your publicly displayed username. You can change this later in the preferences."
|
||||||
openid: "%{logo} OpenID:"
|
external auth: "Third Party Authentication:"
|
||||||
password: "Password:"
|
password: "Password:"
|
||||||
confirm password: "Confirm Password:"
|
confirm password: "Confirm Password:"
|
||||||
use openid: "Alternatively, use %{logo} OpenID to login"
|
use external auth: "Alternatively, use a third party to login"
|
||||||
openid no password: "With OpenID a password is not required, but some extra tools or server may still need one."
|
auth no password: "With third party authentication a password is not required, but some extra tools or server may still need one."
|
||||||
openid association: |
|
auth association: |
|
||||||
<p>Your OpenID is not associated with a OpenStreetMap account yet.</p>
|
<p>Your ID is not associated with a OpenStreetMap account yet.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>If you are new to OpenStreetMap, please create a new account using the form below.</li>
|
<li>If you are new to OpenStreetMap, please create a new account using the form below.</li>
|
||||||
<li>
|
<li>
|
||||||
If you already have an account, you can login to your account
|
If you already have an account, you can login to your account
|
||||||
using your username and password and then associate the account
|
using your username and password and then associate the account
|
||||||
with your OpenID in your user settings.
|
with your ID in your user settings.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
continue: Sign Up
|
continue: Sign Up
|
||||||
|
@ -1857,8 +1857,8 @@ en:
|
||||||
current email address: "Current Email Address:"
|
current email address: "Current Email Address:"
|
||||||
new email address: "New Email Address:"
|
new email address: "New Email Address:"
|
||||||
email never displayed publicly: "(never displayed publicly)"
|
email never displayed publicly: "(never displayed publicly)"
|
||||||
|
external auth: "External Authentication:"
|
||||||
openid:
|
openid:
|
||||||
openid: "OpenID:"
|
|
||||||
link: "http://wiki.openstreetmap.org/wiki/OpenID"
|
link: "http://wiki.openstreetmap.org/wiki/OpenID"
|
||||||
link text: "what is this?"
|
link text: "what is this?"
|
||||||
public editing:
|
public editing:
|
||||||
|
|
11
db/migrate/20150222101847_rename_openid_url.rb
Normal file
11
db/migrate/20150222101847_rename_openid_url.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class RenameOpenidUrl < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :users, :openid_url, :auth_uid
|
||||||
|
add_column :users, :auth_provider, :string
|
||||||
|
|
||||||
|
User.where.not(:auth_uid => nil).update_all(:auth_provider => "openid")
|
||||||
|
|
||||||
|
add_index :users, [:auth_provider, :auth_uid], :unique => true, :name => "users_auth_idx"
|
||||||
|
remove_index :users, :column => :auth_uid, :unique => true, :name => "user_openid_url_idx"
|
||||||
|
end
|
||||||
|
end
|
|
@ -120,6 +120,33 @@ CREATE TYPE user_status_enum AS ENUM (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: maptile_for_point(bigint, bigint, integer); Type: FUNCTION; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE FUNCTION maptile_for_point(bigint, bigint, integer) RETURNS integer
|
||||||
|
LANGUAGE c STRICT
|
||||||
|
AS '/srv/www/omniauth.osm.compton.nu/db/functions/libpgosm.so', 'maptile_for_point';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: tile_for_point(integer, integer); Type: FUNCTION; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE FUNCTION tile_for_point(integer, integer) RETURNS bigint
|
||||||
|
LANGUAGE c STRICT
|
||||||
|
AS '/srv/www/omniauth.osm.compton.nu/db/functions/libpgosm.so', 'tile_for_point';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: xid_to_int4(xid); Type: FUNCTION; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE FUNCTION xid_to_int4(xid) RETURNS integer
|
||||||
|
LANGUAGE c IMMUTABLE STRICT
|
||||||
|
AS '/srv/www/omniauth.osm.compton.nu/db/functions/libpgosm.so', 'xid_to_int4';
|
||||||
|
|
||||||
|
|
||||||
SET default_tablespace = '';
|
SET default_tablespace = '';
|
||||||
|
|
||||||
SET default_with_oids = false;
|
SET default_with_oids = false;
|
||||||
|
@ -1080,7 +1107,7 @@ CREATE TABLE users (
|
||||||
status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL,
|
status user_status_enum DEFAULT 'pending'::user_status_enum NOT NULL,
|
||||||
terms_agreed timestamp without time zone,
|
terms_agreed timestamp without time zone,
|
||||||
consider_pd boolean DEFAULT false NOT NULL,
|
consider_pd boolean DEFAULT false NOT NULL,
|
||||||
openid_url character varying,
|
auth_uid character varying,
|
||||||
preferred_editor character varying,
|
preferred_editor character varying,
|
||||||
terms_seen boolean DEFAULT false NOT NULL,
|
terms_seen boolean DEFAULT false NOT NULL,
|
||||||
description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL,
|
description_format format_enum DEFAULT 'markdown'::format_enum NOT NULL,
|
||||||
|
@ -1089,7 +1116,8 @@ CREATE TABLE users (
|
||||||
traces_count integer DEFAULT 0 NOT NULL,
|
traces_count integer DEFAULT 0 NOT NULL,
|
||||||
diary_entries_count integer DEFAULT 0 NOT NULL,
|
diary_entries_count integer DEFAULT 0 NOT NULL,
|
||||||
image_use_gravatar boolean DEFAULT true NOT NULL,
|
image_use_gravatar boolean DEFAULT true NOT NULL,
|
||||||
image_content_type character varying
|
image_content_type character varying,
|
||||||
|
auth_provider character varying
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1943,13 +1971,6 @@ CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (v
|
||||||
CREATE INDEX user_id_idx ON friends USING btree (friend_user_id);
|
CREATE INDEX user_id_idx ON friends USING btree (friend_user_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: user_openid_url_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX user_openid_url_idx ON users USING btree (openid_url);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
-- Name: user_roles_id_role_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
|
@ -1971,6 +1992,13 @@ CREATE UNIQUE INDEX user_tokens_token_idx ON user_tokens USING btree (token);
|
||||||
CREATE INDEX user_tokens_user_id_idx ON user_tokens USING btree (user_id);
|
CREATE INDEX user_tokens_user_id_idx ON user_tokens USING btree (user_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: users_auth_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX users_auth_idx ON users USING btree (auth_provider, auth_uid);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
-- Name: users_display_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
|
@ -2518,6 +2546,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150110152606');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150111192335');
|
INSERT INTO schema_migrations (version) VALUES ('20150111192335');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150222101847');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('21');
|
INSERT INTO schema_migrations (version) VALUES ('21');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('22');
|
INSERT INTO schema_migrations (version) VALUES ('22');
|
||||||
|
|
|
@ -886,7 +886,8 @@ class UserControllerTest < ActionController::TestCase
|
||||||
assert_equal false, user.image.file?
|
assert_equal false, user.image.file?
|
||||||
assert_equal false, user.email_valid
|
assert_equal false, user.email_valid
|
||||||
assert_nil user.new_email
|
assert_nil user.new_email
|
||||||
assert_nil user.openid_url
|
assert_nil user.auth_provider
|
||||||
|
assert_nil user.auth_uid
|
||||||
assert_equal "deleted", user.status
|
assert_equal "deleted", user.status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
3
test/fixtures/users.yml
vendored
3
test/fixtures/users.yml
vendored
|
@ -107,7 +107,8 @@ openid_user:
|
||||||
creation_time: "2008-05-01 01:23:45"
|
creation_time: "2008-05-01 01:23:45"
|
||||||
display_name: openIDuser
|
display_name: openIDuser
|
||||||
data_public: true
|
data_public: true
|
||||||
openid_url: http://localhost:1123/john.doe
|
auth_provider: openid
|
||||||
|
auth_uid: http://localhost:1123/john.doe
|
||||||
terms_agreed: "2010-01-01 11:22:33"
|
terms_agreed: "2010-01-01 11:22:33"
|
||||||
terms_seen: true
|
terms_seen: true
|
||||||
languages: en
|
languages: en
|
||||||
|
|
|
@ -156,7 +156,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
assert_difference("User.count") do
|
assert_difference("User.count") do
|
||||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||||
post "/user/new",
|
post "/user/new",
|
||||||
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
|
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
@ -166,7 +166,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to "/user/terms"
|
assert_redirected_to "/user/terms"
|
||||||
post "/user/save",
|
post "/user/save",
|
||||||
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/new.tester", :pass_crypt => password, :pass_crypt_confirmation => password }
|
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => password, :pass_crypt_confirmation => password }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
end
|
end
|
||||||
|
@ -187,7 +187,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
assert_difference("User.count", 0) do
|
assert_difference("User.count", 0) do
|
||||||
assert_difference("ActionMailer::Base.deliveries.size", 0) do
|
assert_difference("ActionMailer::Base.deliveries.size", 0) do
|
||||||
post "/user/new",
|
post "/user/new",
|
||||||
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
|
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
@ -217,7 +217,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
assert_difference("User.count") do
|
assert_difference("User.count") do
|
||||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||||
post "/user/new",
|
post "/user/new",
|
||||||
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
|
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
@ -227,7 +227,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to "/user/terms"
|
assert_redirected_to "/user/terms"
|
||||||
post_via_redirect "/user/save",
|
post_via_redirect "/user/save",
|
||||||
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
|
:user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :auth_provider => "openid", :auth_uid => "http://localhost:1123/new.tester", :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue