Merge branch 'features/mix-task-reset-mfa' into 'develop'
New mix task: pleroma.user reset_mfa <nickname> See merge request pleroma/pleroma!2643
This commit is contained in:
commit
6d902916dd
|
@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Configuration: `filename_display_max_length` option to set filename truncate limit, if filename display enabled (0 = no limit).
|
- Configuration: `filename_display_max_length` option to set filename truncate limit, if filename display enabled (0 = no limit).
|
||||||
- New HTTP adapter [gun](https://github.com/ninenines/gun). Gun adapter requires minimum OTP version of 22.2 otherwise Pleroma won’t start. For hackney OTP update is not required.
|
- New HTTP adapter [gun](https://github.com/ninenines/gun). Gun adapter requires minimum OTP version of 22.2 otherwise Pleroma won’t start. For hackney OTP update is not required.
|
||||||
- Mix task to create trusted OAuth App.
|
- Mix task to create trusted OAuth App.
|
||||||
|
- Mix task to reset MFA for user accounts
|
||||||
- Notifications: Added `follow_request` notification type.
|
- Notifications: Added `follow_request` notification type.
|
||||||
- Added `:reject_deletes` group to SimplePolicy
|
- Added `:reject_deletes` group to SimplePolicy
|
||||||
- MRF (`EmojiStealPolicy`): New MRF Policy which allows to automatically download emojis from remote instances
|
- MRF (`EmojiStealPolicy`): New MRF Policy which allows to automatically download emojis from remote instances
|
||||||
|
|
|
@ -135,6 +135,16 @@ mix pleroma.user reset_password <nickname>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Disable Multi Factor Authentication (MFA/2FA) for a user
|
||||||
|
```sh tab="OTP"
|
||||||
|
./bin/pleroma_ctl user reset_mfa <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh tab="From Source"
|
||||||
|
mix pleroma.user reset_mfa <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Set the value of the given user's settings
|
## Set the value of the given user's settings
|
||||||
```sh tab="OTP"
|
```sh tab="OTP"
|
||||||
./bin/pleroma_ctl user set <nickname> [option ...]
|
./bin/pleroma_ctl user set <nickname> [option ...]
|
||||||
|
|
|
@ -144,6 +144,18 @@ def run(["reset_password", nickname]) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run(["reset_mfa", nickname]) do
|
||||||
|
start_pleroma()
|
||||||
|
|
||||||
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname),
|
||||||
|
{:ok, _token} <- Pleroma.MFA.disable(user) do
|
||||||
|
shell_info("Multi-Factor Authentication disabled for #{user.nickname}")
|
||||||
|
else
|
||||||
|
_ ->
|
||||||
|
shell_error("No local user #{nickname}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def run(["deactivate", nickname]) do
|
def run(["deactivate", nickname]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
defmodule Mix.Tasks.Pleroma.UserTest do
|
defmodule Mix.Tasks.Pleroma.UserTest do
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
|
alias Pleroma.MFA
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.Tests.ObanHelpers
|
alias Pleroma.Tests.ObanHelpers
|
||||||
|
@ -278,6 +279,35 @@ test "no user to reset password" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "running reset_mfa" do
|
||||||
|
test "disables MFA" do
|
||||||
|
user =
|
||||||
|
insert(:user,
|
||||||
|
multi_factor_authentication_settings: %MFA.Settings{
|
||||||
|
enabled: true,
|
||||||
|
totp: %MFA.Settings.TOTP{secret: "xx", confirmed: true}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Mix.Tasks.Pleroma.User.run(["reset_mfa", user.nickname])
|
||||||
|
|
||||||
|
assert_received {:mix_shell, :info, [message]}
|
||||||
|
assert message == "Multi-Factor Authentication disabled for #{user.nickname}"
|
||||||
|
|
||||||
|
assert %{enabled: false, totp: false} ==
|
||||||
|
user.nickname
|
||||||
|
|> User.get_cached_by_nickname()
|
||||||
|
|> MFA.mfa_settings()
|
||||||
|
end
|
||||||
|
|
||||||
|
test "no user to reset MFA" do
|
||||||
|
Mix.Tasks.Pleroma.User.run(["reset_password", "nonexistent"])
|
||||||
|
|
||||||
|
assert_received {:mix_shell, :error, [message]}
|
||||||
|
assert message =~ "No local user"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "running invite" do
|
describe "running invite" do
|
||||||
test "invite token is generated" do
|
test "invite token is generated" do
|
||||||
assert capture_io(fn ->
|
assert capture_io(fn ->
|
||||||
|
|
Loading…
Reference in New Issue