diff options
author | Ivan Tashkinov <ivant.business@gmail.com> | 2019-03-18 18:09:53 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivant.business@gmail.com> | 2019-03-18 18:09:53 +0300 |
commit | 8d21859717a75e01128f50b0b51efdd0a4748670 (patch) | |
tree | 3b9930098bfccb8ea8ce4b0fa96e56152d791a22 /lib/pleroma/web/auth | |
parent | 26b63540953f6a65bb52531b434fd6ab85aaedfe (diff) | |
download | pleroma-8d21859717a75e01128f50b0b51efdd0a4748670.tar.gz |
[#923] External User registration refactoring, password randomization.
Diffstat (limited to 'lib/pleroma/web/auth')
-rw-r--r-- | lib/pleroma/web/auth/pleroma_authenticator.ex | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/pleroma/web/auth/pleroma_authenticator.ex b/lib/pleroma/web/auth/pleroma_authenticator.ex index 2d4399490..36ecd0560 100644 --- a/lib/pleroma/web/auth/pleroma_authenticator.ex +++ b/lib/pleroma/web/auth/pleroma_authenticator.ex @@ -54,20 +54,26 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticator do # Note: generating a random numeric suffix to nickname in case this nickname is already taken nickname = if nickname && User.get_by_nickname(nickname) do - "#{nickname}_#{:os.system_time()}" + "#{nickname}#{:os.system_time()}" else nickname end + random_password = :crypto.strong_rand_bytes(64) |> Base.encode64() + with {:ok, new_user} <- - User.external_registration_changeset( + User.register_changeset( %User{}, %{ name: info.name, bio: info.description, email: email, - nickname: nickname - } + nickname: nickname, + password: random_password, + password_confirmation: random_password + }, + external: true, + confirmed: true ) |> Repo.insert(), {:ok, _} <- |