BUGFIX: twitter auth asking for a password

This commit is contained in:
Sam 2014-03-20 14:49:25 +11:00
parent 52fbce07ed
commit 619fa50d4b
3 changed files with 9 additions and 1 deletions

View file

@ -46,7 +46,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
}.property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted', 'tosAccepted'), }.property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted', 'tosAccepted'),
passwordRequired: function() { passwordRequired: function() {
return (this.blank('authOptions.auth_provider') || this.blank('authOptions.email_valid') || !this.get('authOptions.email_valid')); return this.blank('authOptions.auth_provider');
}.property('authOptions.auth_provider'), }.property('authOptions.auth_provider'),
passwordInstructions: function() { passwordInstructions: function() {

View file

@ -128,6 +128,10 @@ class UsersController < ApplicationController
activation = UserActivator.new(user, request, session, cookies) activation = UserActivator.new(user, request, session, cookies)
activation.start activation.start
# just assign a password if we have an authenticator and no password
# this is the case for Twitter
user.password = SecureRandom.hex if user.password.blank? && authentication.has_authenticator?
if user.save if user.save
authentication.finish authentication.finish
activation.finish activation.finish

View file

@ -13,6 +13,10 @@ class UserAuthenticator
end end
end end
def has_authenticator?
!!authenticator
end
def finish def finish
if authenticator if authenticator
authenticator.after_create_account(@user, @session) authenticator.after_create_account(@user, @session)