Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic User management #2529

Merged
merged 39 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e27f7a6
Enforce password security un user schema
CDimonaco Apr 16, 2024
3f61045
Argon2 hash algorithm for user password
CDimonaco Apr 16, 2024
a41bf5a
Add fullname and email fields to user schema
CDimonaco Apr 16, 2024
b4a0f47
Mix phx gen json scaffolding for users
CDimonaco Apr 16, 2024
b66ca66
Users context
CDimonaco Apr 16, 2024
1c50ec7
mix format
CDimonaco Apr 16, 2024
3d37636
User controller refactored for the new users context
CDimonaco Apr 16, 2024
48b7259
Pow custom context for getting non-deleted users
CDimonaco Apr 16, 2024
9176627
Unique email for users
CDimonaco Apr 16, 2024
1d68c06
Update release task and seed for users
CDimonaco Apr 16, 2024
0f9524d
Users context prevents deletion of user with id 1
CDimonaco Apr 17, 2024
98abea2
Username cannot be updated
CDimonaco Apr 17, 2024
09fb9c4
Created and updated timestamps in users view
CDimonaco Apr 17, 2024
2f459d9
Change of the username when users are deleted
CDimonaco Apr 17, 2024
bf3767f
Add lock feature to Users
CDimonaco Apr 18, 2024
e31b43d
Locked and deleted users are excluded from renew
CDimonaco Apr 18, 2024
1d4a7d7
Session controller tests updated
CDimonaco Apr 18, 2024
cb2ac49
/me endpoint returns also user id
CDimonaco Apr 18, 2024
5793116
User socket authenticatio
CDimonaco Apr 18, 2024
1165244
User controller broadcast user actions on user topic
CDimonaco Apr 19, 2024
c00ff91
Access token expiration to 3 minutes
CDimonaco Apr 19, 2024
2dd525b
Fix could not delete admin user in context
CDimonaco Apr 19, 2024
1b1cb64
Trento default admin enabled
CDimonaco Apr 19, 2024
0c18d24
User controller with spex
CDimonaco Apr 19, 2024
a6fd890
Fix app jwt auth plug test typo
CDimonaco Apr 19, 2024
efc7267
User controller actions are dispatched to per user channels
CDimonaco Apr 19, 2024
4484b83
fix access token test
CDimonaco Apr 19, 2024
84e2416
fix alias in factory file
CDimonaco Apr 19, 2024
cda1e63
mix credo
CDimonaco Apr 19, 2024
04984e3
fix mispell
CDimonaco Apr 19, 2024
a251e24
mix credo
CDimonaco Apr 19, 2024
a10dc58
removed comments from user_controller_test
CDimonaco Apr 19, 2024
1f3f378
Addressing review feedbacks
CDimonaco Apr 22, 2024
113af0b
Introduced users factory
CDimonaco Apr 22, 2024
2135f14
Addresing feedbacks
CDimonaco Apr 22, 2024
ccce860
Updated trento_dev sql regression dump
CDimonaco Apr 22, 2024
a3a3efc
Revert "Updated trento_dev sql regression dump"
CDimonaco Apr 22, 2024
171e847
Ecto seed with user password update on conflict
CDimonaco Apr 22, 2024
e5f2998
Run db seed on regression tests
CDimonaco Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change of the username when users are deleted
CDimonaco committed Apr 17, 2024
commit 2f459d9dc70efd674f079d414d49234ff1ebadbf
3 changes: 2 additions & 1 deletion lib/trento/users/user.ex
Original file line number Diff line number Diff line change
@@ -42,10 +42,11 @@ defmodule Trento.Users.User do
|> custom_fields_changeset(attrs)
end

def delete_changeset(user, attrs) do
def delete_changeset(%__MODULE__{username: username} = user, %{deleted_at: deleted_at} = attrs) do
user
|> cast(attrs, [:deleted_at])
|> validate_required(:deleted_at)
|> put_change(:username, "#{username}__#{deleted_at}")
end

defp validate_password(changeset) do
7 changes: 6 additions & 1 deletion test/trento/users_test.exs
Original file line number Diff line number Diff line change
@@ -147,9 +147,14 @@ defmodule Trento.UsersTest do
end

test "delete_user/1 deletes the user" do
user = create_user()
%{id: user_id, username: original_username} = user = create_user()
assert {:ok, %User{}} = Users.delete_user(user)
assert {:error, :not_found} == Users.get_user(user.id)

%User{deleted_at: deleted_at, username: username} = Trento.Repo.get_by!(User, id: user_id)

refute deleted_at == nil
refute username == original_username
end
end


Unchanged files with check annotations Beta

alias Faker.Random.Elixir, as: RandomElixir
alias Trento.Users.User

Check warning on line 13 in test/support/factory.ex

GitHub Actions / API bc check (V1)

unused alias User

Check warning on line 13 in test/support/factory.ex

GitHub Actions / API bc check (V2)

unused alias User

Check warning on line 13 in test/support/factory.ex

GitHub Actions / Static Code Analysis

unused alias User

Check warning on line 13 in test/support/factory.ex

GitHub Actions / Test (Elixir 1.15.7, OTP 26)

unused alias User
alias Trento.Clusters.ValueObjects.{
AscsErsClusterDetails,