Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Remove current_organisation_id from the registration form#549

Open
briankariuki wants to merge 5 commits into3Stones-io:mainfrom
briankariuki:refactor/remove-organisation-id
Open

Remove current_organisation_id from the registration form#549
briankariuki wants to merge 5 commits into3Stones-io:mainfrom
briankariuki:refactor/remove-organisation-id

Conversation

@briankariuki
Copy link
Copy Markdown
Contributor

closes #477

render_submit(form)

assert redirected_to(conn) == ~p"/edit_profile"
assert_redirect(view, ~p"/login")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure that the user is logged in automatically after the registration.

|> Ash.read(authorize?: false, tenant: organisation)

assert length(user_group_memberships) == 3
# assert length(user_group_memberships) == 3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

)

_conn = submit_form(form, new_conn)
render_submit(form)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to assert that user is redirected?

|> Map.put("current_organisation_id", socket.assigns.invitation.organisation_id)

form = Form.validate(socket.assigns.form, updated_params)
case AshPhoenix.Form.submit(socket.assigns.form, params: updated_params) do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only validate at this point. The real registration happens in the Ash controller so that the session gets updated and user logged in.

)}
</div>
</div>
<div class="sm:col-span-3">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the register_with_password action, can we check whether the user to be registered has an unexpired invitation in the system? If yes, they should be associated with it and the organisation the invite belongs to.

If not, ask in the Elixir forum how to approach this: https://elixirforum.com/c/ash-framework-forum/123.

Worst case scenario, we can keep the organisation_id in this form and achieve security through obscurity. But there should be a better way.

@almirsarajcic
Copy link
Copy Markdown
Member

@briankariuki, you can take a look at the Ash code as a reference.
While debugging something with Nyakio, we noticed this pattern that they use to pass some data in the form avoiding the hidden input:

https://github.com/team-alembic/ash_authentication_phoenix/blob/810d0d65e5685aeaa5bf85541ce60bc10ae8b601/lib/ash_authentication_phoenix/components/password/reset_form.ex#L143-L160

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove current_organisation_id from the registration form

2 participants