Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -178,9 +178,24 @@ class AccountController < ApplicationController
redirect_to(home_url) && return unless Setting.self_registration?
# Create on the fly
- user.login = registration['nickname'] unless registration['nickname'].nil?
- user.mail = registration['email'] unless registration['email'].nil?
- user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
+ if !registration['nickname'].nil?
+ user.login = registration['nickname']
+ else
+ user.login = ActiveSupport::SecureRandom.hex(6)
+ end
+
+ if !registration['email'].nil?
+ user.mail = registration['email']
+ else
+ user.mail = "please_update_your_email_" + user.login + "@domain.com"
+ end
+
+ if !registration['fullname'].nil?
+ user.firstname, user.lastname = registration['fullname'].split(' ')
+ else
+ user.firstname = user.login
+ user.lastname = "-"
+ end
user.random_password
user.status = User::STATUS_REGISTERED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment