This is page 5 of 10. Use http://codebase.md/m-gonzalo/cosa-sai?lines=true&page={x} to view the full context.
# Directory Structure
```
├── .gitignore
├── bun.lock
├── Dockerfile
├── package.json
├── prompts
│ └── default.txt
├── README.md
├── smithery.yaml
├── src
│ ├── db.ts
│ ├── gemini.ts
│ ├── index.ts
│ ├── logger.ts
│ └── types.ts
├── test
│ ├── docs
│ │ ├── ash-docs
│ │ │ ├── ash_admin.md
│ │ │ ├── ash_appsignal.md
│ │ │ ├── ash_archival.md
│ │ │ ├── ash_authentication_phoenix.md
│ │ │ ├── ash_authentication.md
│ │ │ ├── ash_cloak.md
│ │ │ ├── ash_csv.md
│ │ │ ├── ash_cubdb.md
│ │ │ ├── ash_double_entry.md
│ │ │ ├── ash_graphql.md
│ │ │ ├── ash_json_api.md
│ │ │ ├── ash_money.md
│ │ │ ├── ash_oban.md
│ │ │ ├── ash_phoenix.md
│ │ │ ├── ash_postgres.md
│ │ │ ├── ash_rbac.md
│ │ │ ├── ash_sqlite.md
│ │ │ ├── ash_state_machine.md
│ │ │ └── ash.md
│ │ ├── bun-elysia-docs
│ │ │ ├── bun.sh.md
│ │ │ └── elysiajs.com.md
│ │ ├── javascript-docs
│ │ │ └── sample.md
│ │ └── phoenix-docs
│ │ └── phx-docs.md
│ └── prompts
│ ├── ash-framework.txt
│ ├── bun-elysia.txt
│ ├── javascript.txt
│ └── phoenix.txt
└── tsconfig.json
```
# Files
--------------------------------------------------------------------------------
/test/docs/ash-docs/ash_authentication_phoenix.md:
--------------------------------------------------------------------------------
```markdown
1 | [ash\_authentication\_phoenix](readme.html)
2 |
3 | v2.4.5
4 |
5 | - Pages
6 | - Modules
7 | - Mix Tasks
8 |
9 | <!--THE END-->
10 |
11 | <!--THE END-->
12 |
13 | <!--THE END-->
14 |
15 | Search documentation of ash\_authentication\_phoenix
16 |
17 | Settings
18 |
19 | # API Reference ash\_authentication\_phoenix v2.4.5
20 |
21 | ## [](api-reference.html#modules)Modules
22 |
23 | [AshAuthentication.Phoenix](AshAuthentication.Phoenix.html)
24 |
25 | Welcome to `AshAuthentication.Pheonix`.
26 |
27 | [AshAuthentication.Phoenix.Components.Apple](AshAuthentication.Phoenix.Components.Apple.html)
28 |
29 | Generates a sign-in button for Apple.
30 |
31 | [AshAuthentication.Phoenix.Components.Banner](AshAuthentication.Phoenix.Components.Banner.html)
32 |
33 | Renders a very simple banner at the top of the sign-in component.
34 |
35 | [AshAuthentication.Phoenix.Components.Helpers](AshAuthentication.Phoenix.Components.Helpers.html)
36 |
37 | Helpers which are commonly needed inside the various components.
38 |
39 | [AshAuthentication.Phoenix.Components.HorizontalRule](AshAuthentication.Phoenix.Components.HorizontalRule.html)
40 |
41 | A horizontal rule with text.
42 |
43 | [AshAuthentication.Phoenix.Components.MagicLink](AshAuthentication.Phoenix.Components.MagicLink.html)
44 |
45 | Generates a sign-in for for a resource using the "Magic link" strategy.
46 |
47 | [AshAuthentication.Phoenix.Components.OAuth2](AshAuthentication.Phoenix.Components.OAuth2.html)
48 |
49 | Generates a sign-in button for OAuth2.
50 |
51 | [AshAuthentication.Phoenix.Components.Password](AshAuthentication.Phoenix.Components.Password.html)
52 |
53 | Generates sign in, registration and reset forms for a resource.
54 |
55 | [AshAuthentication.Phoenix.Components.Password.Input](AshAuthentication.Phoenix.Components.Password.Input.html)
56 |
57 | Function components for dealing with form input during password authentication.
58 |
59 | [AshAuthentication.Phoenix.Components.Password.RegisterForm](AshAuthentication.Phoenix.Components.Password.RegisterForm.html)
60 |
61 | Generates a default registration form.
62 |
63 | [AshAuthentication.Phoenix.Components.Password.ResetForm](AshAuthentication.Phoenix.Components.Password.ResetForm.html)
64 |
65 | Generates a default password reset form.
66 |
67 | [AshAuthentication.Phoenix.Components.Password.SignInForm](AshAuthentication.Phoenix.Components.Password.SignInForm.html)
68 |
69 | Generates a default sign in form.
70 |
71 | [AshAuthentication.Phoenix.Components.Reset](AshAuthentication.Phoenix.Components.Reset.html)
72 |
73 | Renders a password-reset form.
74 |
75 | [AshAuthentication.Phoenix.Components.Reset.Form](AshAuthentication.Phoenix.Components.Reset.Form.html)
76 |
77 | Generates a default password reset form.
78 |
79 | [AshAuthentication.Phoenix.Components.SignIn](AshAuthentication.Phoenix.Components.SignIn.html)
80 |
81 | Renders sign in mark-up for an authenticated resource.
82 |
83 | [AshAuthentication.Phoenix.Controller](AshAuthentication.Phoenix.Controller.html)
84 |
85 | The authentication controller generator.
86 |
87 | [AshAuthentication.Phoenix.LiveSession](AshAuthentication.Phoenix.LiveSession.html)
88 |
89 | Ensures that any loaded users which are present in a conn's assigns are also present in a live view socket's assigns.
90 |
91 | [AshAuthentication.Phoenix.Overrides](AshAuthentication.Phoenix.Overrides.html)
92 |
93 | Behaviour for overriding component styles and attributes in your application.
94 |
95 | [AshAuthentication.Phoenix.Overrides.Default](AshAuthentication.Phoenix.Overrides.Default.html)
96 |
97 | This is the default overrides for our component UI.
98 |
99 | [AshAuthentication.Phoenix.Overrides.Info](AshAuthentication.Phoenix.Overrides.Info.html)
100 |
101 | Override introspection.
102 |
103 | [AshAuthentication.Phoenix.Overrides.Overridable](AshAuthentication.Phoenix.Overrides.Overridable.html)
104 |
105 | Auto generates documentation and helpers for components.
106 |
107 | [AshAuthentication.Phoenix.Plug](AshAuthentication.Phoenix.Plug.html)
108 |
109 | Helper plugs mixed in to your router.
110 |
111 | [AshAuthentication.Phoenix.ResetLive](AshAuthentication.Phoenix.ResetLive.html)
112 |
113 | A generic, white-label password reset page.
114 |
115 | [AshAuthentication.Phoenix.Router](AshAuthentication.Phoenix.Router.html)
116 |
117 | Phoenix route generation for AshAuthentication.
118 |
119 | [AshAuthentication.Phoenix.SignInLive](AshAuthentication.Phoenix.SignInLive.html)
120 |
121 | A generic, white-label sign-in page.
122 |
123 | [AshAuthentication.Phoenix.Test.Gettext](AshAuthentication.Phoenix.Test.Gettext.html)
124 |
125 | Gettext stub, referenced in AshAuthentication.Phoenix.Test.Router
126 |
127 | [AshAuthentication.Phoenix.Utils.Flash](AshAuthentication.Phoenix.Utils.Flash.html)
128 |
129 | Utility functions for sending and receiving flash messages.
130 |
131 | ## [](api-reference.html#mix-tasks)Mix Tasks
132 |
133 | [mix ash\_authentication.phoenix.routes](Mix.Tasks.AshAuthentication.Phoenix.Routes.html)
134 |
135 | Prints all routes pertaining to AshAuthenticationPhoenix for the default or a given router.
136 |
137 | [mix ash\_authentication\_phoenix.install](Mix.Tasks.AshAuthenticationPhoenix.Install.html)
138 |
139 | Installs AshAuthenticationPhoenix. Invoke with `mix igniter.install ash_authentication_phoenix`
140 |
141 | [Next Page → README](readme.html)
142 |
143 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
144 |
145 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
146 | [ash\_authentication\_phoenix](readme.html)
147 |
148 | v2.4.5
149 |
150 | - Pages
151 | - Modules
152 | - Mix Tasks
153 |
154 | <!--THE END-->
155 |
156 | <!--THE END-->
157 |
158 | <!--THE END-->
159 |
160 | Search documentation of ash\_authentication\_phoenix
161 |
162 | Settings
163 |
164 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/apple.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Apple (ash\_authentication\_phoenix v2.4.5)
165 |
166 | Generates a sign-in button for Apple.
167 |
168 | ## [](AshAuthentication.Phoenix.Components.Apple.html#module-component-hierarchy)Component hierarchy
169 |
170 | This is the top-most strategy-specific component, nested below [`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html).
171 |
172 | ## [](AshAuthentication.Phoenix.Components.Apple.html#module-props)Props
173 |
174 | - `strategy` - The strategy configuration as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
175 | - `overrides` - A list of override modules.
176 | - `gettext_fn` - Optional text translation function.
177 |
178 | ## [](AshAuthentication.Phoenix.Components.Apple.html#module-overrides)Overrides
179 |
180 | This component provides the following overrides:
181 |
182 | - `:root_class` - CSS classes for the root `div` element.
183 | - `:link_class` - CSS classes for the `a` element.
184 | - `:icon_class` - CSS classes for the icon SVG.
185 |
186 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
187 |
188 | # [](AshAuthentication.Phoenix.Components.Apple.html#summary)Summary
189 |
190 | ## [Types](AshAuthentication.Phoenix.Components.Apple.html#types)
191 |
192 | [props()](AshAuthentication.Phoenix.Components.Apple.html#t:props/0)
193 |
194 | ## [Functions](AshAuthentication.Phoenix.Components.Apple.html#functions)
195 |
196 | [icon(assigns)](AshAuthentication.Phoenix.Components.Apple.html#icon/1)
197 |
198 | # [](AshAuthentication.Phoenix.Components.Apple.html#types)Types
199 |
200 | [](AshAuthentication.Phoenix.Components.Apple.html#t:props/0)
201 |
202 | # props()
203 |
204 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/apple.ex#L31)
205 |
206 | ```
207 | @type props() :: %{
208 | :strategy => AshAuthentication.Strategy.t(),
209 | optional(:overrides) => [module()],
210 | optional(:gettext_fn) => {module(), atom()}
211 | }
212 | ```
213 |
214 | # [](AshAuthentication.Phoenix.Components.Apple.html#functions)Functions
215 |
216 | [](AshAuthentication.Phoenix.Components.Apple.html#icon/1)
217 |
218 | # icon(assigns)
219 |
220 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/apple.ex#L66)
221 |
222 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
223 |
224 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
225 | [ash\_authentication\_phoenix](readme.html)
226 |
227 | v2.4.5
228 |
229 | - Pages
230 | - Modules
231 | - Mix Tasks
232 |
233 | <!--THE END-->
234 |
235 | <!--THE END-->
236 |
237 | <!--THE END-->
238 |
239 | Search documentation of ash\_authentication\_phoenix
240 |
241 | Settings
242 |
243 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/banner.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Banner (ash\_authentication\_phoenix v2.4.5)
244 |
245 | Renders a very simple banner at the top of the sign-in component.
246 |
247 | Can show either an image or some text, depending on the provided overrides.
248 |
249 | ## [](AshAuthentication.Phoenix.Components.Banner.html#module-props)Props
250 |
251 | - `overrides` - A list of override modules.
252 | - `gettext_fn` - Optional text translation function.
253 |
254 | ## [](AshAuthentication.Phoenix.Components.Banner.html#module-overrides)Overrides
255 |
256 | This component provides the following overrides:
257 |
258 | - `:text` - Banner text. Set to `nil` to disable.
259 | - `:root_class` - CSS class for the root `div` element.
260 | - `:href_class` - CSS class for the `a` tag.
261 | - `:href_url` - A URL for the banner image to link to. Set to `nil` to disable.
262 | - `:image_class` - CSS class for the `img` tag.
263 | - `:dark_image_class` - Css class for the `img` tag in dark mode.
264 | - `:image_url` - A URL for the `img` `src` attribute. Set to `nil` to disable.
265 | - `:dark_image_url` - A URL for the `img` `src` attribute in dark mode. Set to `nil` to disable.
266 | - `:text_class` - CSS class for the text `div`.
267 |
268 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
269 |
270 | # [](AshAuthentication.Phoenix.Components.Banner.html#summary)Summary
271 |
272 | ## [Types](AshAuthentication.Phoenix.Components.Banner.html#types)
273 |
274 | [props()](AshAuthentication.Phoenix.Components.Banner.html#t:props/0)
275 |
276 | # [](AshAuthentication.Phoenix.Components.Banner.html#types)Types
277 |
278 | [](AshAuthentication.Phoenix.Components.Banner.html#t:props/0)
279 |
280 | # props()
281 |
282 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/banner.ex#L29)
283 |
284 | ```
285 | @type props() :: %{
286 | optional(:overrides) => [module()],
287 | optional(:gettext_fn) => {module(), atom()}
288 | }
289 | ```
290 |
291 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
292 |
293 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
294 | [ash\_authentication\_phoenix](readme.html)
295 |
296 | v2.4.5
297 |
298 | - Pages
299 | - Modules
300 | - Mix Tasks
301 |
302 | <!--THE END-->
303 |
304 | <!--THE END-->
305 |
306 | <!--THE END-->
307 |
308 | Search documentation of ash\_authentication\_phoenix
309 |
310 | Settings
311 |
312 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/helpers.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Helpers (ash\_authentication\_phoenix v2.4.5)
313 |
314 | Helpers which are commonly needed inside the various components.
315 |
316 | # [](AshAuthentication.Phoenix.Components.Helpers.html#summary)Summary
317 |
318 | ## [Functions](AshAuthentication.Phoenix.Components.Helpers.html#functions)
319 |
320 | [auth\_path(socket, subject\_name, auth\_routes\_prefix, strategy, phase, params \\\\ %{})](AshAuthentication.Phoenix.Components.Helpers.html#auth_path/6)
321 |
322 | [otp\_app\_from\_socket(socket)](AshAuthentication.Phoenix.Components.Helpers.html#otp_app_from_socket/1)
323 |
324 | The LiveView `Socket` contains a reference to the Phoenix endpoint, and from there we can extract the `otp_app` of the current request.
325 |
326 | [route\_helpers(socket)](AshAuthentication.Phoenix.Components.Helpers.html#route_helpers/1)
327 |
328 | The LiveView `Socket` contains a refererence to the Phoenix router, and from there we can generate the name of the route helpers module.
329 |
330 | # [](AshAuthentication.Phoenix.Components.Helpers.html#functions)Functions
331 |
332 | [](AshAuthentication.Phoenix.Components.Helpers.html#auth_path/6)
333 |
334 | # auth\_path(socket, subject\_name, auth\_routes\_prefix, strategy, phase, params \\\\ %{})
335 |
336 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/helpers.ex#L21)
337 |
338 | [](AshAuthentication.Phoenix.Components.Helpers.html#otp_app_from_socket/1)
339 |
340 | # otp\_app\_from\_socket(socket)
341 |
342 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/helpers.ex#L15)
343 |
344 | ```
345 | @spec otp_app_from_socket(Phoenix.LiveView.Socket.t()) :: atom()
346 | ```
347 |
348 | The LiveView `Socket` contains a reference to the Phoenix endpoint, and from there we can extract the `otp_app` of the current request.
349 |
350 | This is pulled from `assigns[:otp_app]`, or inferred from the socket if that is not set.
351 |
352 | [](AshAuthentication.Phoenix.Components.Helpers.html#route_helpers/1)
353 |
354 | # route\_helpers(socket)
355 |
356 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/helpers.ex#L53)
357 |
358 | ```
359 | @spec route_helpers(Phoenix.LiveView.Socket.t()) :: module()
360 | ```
361 |
362 | The LiveView `Socket` contains a refererence to the Phoenix router, and from there we can generate the name of the route helpers module.
363 |
364 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
365 |
366 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
367 | [ash\_authentication\_phoenix](readme.html)
368 |
369 | v2.4.5
370 |
371 | - Pages
372 | - Modules
373 | - Mix Tasks
374 |
375 | <!--THE END-->
376 |
377 | <!--THE END-->
378 |
379 | <!--THE END-->
380 |
381 | Search documentation of ash\_authentication\_phoenix
382 |
383 | Settings
384 |
385 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/horizontal_rule.ex#L1 "View Source") AshAuthentication.Phoenix.Components.HorizontalRule (ash\_authentication\_phoenix v2.4.5)
386 |
387 | A horizontal rule with text.
388 |
389 | This component is pretty tailwind-specific, but I (@jimsynz) really wanted a certain look. If you think I'm wrong then please let me know.
390 |
391 | ## [](AshAuthentication.Phoenix.Components.HorizontalRule.html#module-overrides)Overrides
392 |
393 | This component provides the following overrides:
394 |
395 | - `:text` - Text to display in front of the horizontal rule.
396 | - `:root_class` - CSS class for the root `div` element.
397 | - `:hr_outer_class` - CSS class for the outer `div` element of the horizontal rule.
398 | - `:hr_inner_class` - CSS class for the inner `div` element of the horizontal rule.
399 | - `:text_outer_class` - CSS class for the outer `div` element of the text area.
400 | - `:text_inner_class` - CSS class for the inner `div` element of the text area.
401 |
402 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
403 |
404 | ## [](AshAuthentication.Phoenix.Components.HorizontalRule.html#module-props)Props
405 |
406 | ```
407 | * `overrides` - A list of override modules.
408 | ```
409 |
410 | # [](AshAuthentication.Phoenix.Components.HorizontalRule.html#summary)Summary
411 |
412 | ## [Types](AshAuthentication.Phoenix.Components.HorizontalRule.html#types)
413 |
414 | [props()](AshAuthentication.Phoenix.Components.HorizontalRule.html#t:props/0)
415 |
416 | # [](AshAuthentication.Phoenix.Components.HorizontalRule.html#types)Types
417 |
418 | [](AshAuthentication.Phoenix.Components.HorizontalRule.html#t:props/0)
419 |
420 | # props()
421 |
422 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/horizontal_rule.ex#L26)
423 |
424 | ```
425 | @type props() :: %{optional(:overrides) => [module()]}
426 | ```
427 |
428 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
429 |
430 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
431 | [ash\_authentication\_phoenix](readme.html)
432 |
433 | v2.4.5
434 |
435 | - Pages
436 | - Modules
437 | - Mix Tasks
438 |
439 | <!--THE END-->
440 |
441 | <!--THE END-->
442 |
443 | <!--THE END-->
444 |
445 | Search documentation of ash\_authentication\_phoenix
446 |
447 | Settings
448 |
449 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/magic_link.ex#L1 "View Source") AshAuthentication.Phoenix.Components.MagicLink (ash\_authentication\_phoenix v2.4.5)
450 |
451 | Generates a sign-in for for a resource using the "Magic link" strategy.
452 |
453 | ## [](AshAuthentication.Phoenix.Components.MagicLink.html#module-component-hierarchy)Component hierarchy
454 |
455 | This is the top-most strategy-specific component, nested below [`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html).
456 |
457 | Children:
458 |
459 | - [`AshAuthentication.Phoenix.Components.Password.Input.identity_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
460 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
461 |
462 | ## [](AshAuthentication.Phoenix.Components.MagicLink.html#module-props)Props
463 |
464 | - `strategy` - the strategy configuration as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
465 | - `overrides` - A list of override modules.
466 | - `gettext_fn` - Optional text translation function.
467 |
468 | ## [](AshAuthentication.Phoenix.Components.MagicLink.html#module-overrides)Overrides
469 |
470 | This component provides the following overrides:
471 |
472 | - `:root_class` - CSS class for the root `div` element.
473 | - `:label_class` - CSS class for the `h2` element.
474 | - `:form_class` - CSS class for the `form` element.
475 | - `:disable_button_text` - Text for the submit button when the request is happening.
476 | - `:request_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.
477 |
478 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
479 |
480 | # [](AshAuthentication.Phoenix.Components.MagicLink.html#summary)Summary
481 |
482 | ## [Types](AshAuthentication.Phoenix.Components.MagicLink.html#types)
483 |
484 | [props()](AshAuthentication.Phoenix.Components.MagicLink.html#t:props/0)
485 |
486 | # [](AshAuthentication.Phoenix.Components.MagicLink.html#types)Types
487 |
488 | [](AshAuthentication.Phoenix.Components.MagicLink.html#t:props/0)
489 |
490 | # props()
491 |
492 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/magic_link.ex#L41)
493 |
494 | ```
495 | @type props() :: %{
496 | :strategy => AshAuthentication.Strategy.t(),
497 | optional(:current_tenant) => String.t(),
498 | optional(:context) => map(),
499 | optional(:auth_routes_prefix) => String.t(),
500 | optional(:overrides) => [module()],
501 | optional(:gettext_fn) => {module(), atom()}
502 | }
503 | ```
504 |
505 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
506 |
507 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
508 | [ash\_authentication\_phoenix](readme.html)
509 |
510 | v2.4.5
511 |
512 | - Pages
513 | - Modules
514 | - Mix Tasks
515 |
516 | <!--THE END-->
517 |
518 | <!--THE END-->
519 |
520 | <!--THE END-->
521 |
522 | Search documentation of ash\_authentication\_phoenix
523 |
524 | Settings
525 |
526 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/oauth2.ex#L1 "View Source") AshAuthentication.Phoenix.Components.OAuth2 (ash\_authentication\_phoenix v2.4.5)
527 |
528 | Generates a sign-in button for OAuth2.
529 |
530 | ## [](AshAuthentication.Phoenix.Components.OAuth2.html#module-component-hierarchy)Component hierarchy
531 |
532 | This is the top-most strategy-specific component, nested below [`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html).
533 |
534 | ## [](AshAuthentication.Phoenix.Components.OAuth2.html#module-props)Props
535 |
536 | - `strategy` - The strategy configuration as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
537 | - `overrides` - A list of override modules.
538 | - `gettext_fn` - Optional text translation function.
539 |
540 | ## [](AshAuthentication.Phoenix.Components.OAuth2.html#module-overrides)Overrides
541 |
542 | This component provides the following overrides:
543 |
544 | - `:root_class` - CSS classes for the root `div` element.
545 | - `:link_class` - CSS classes for the `a` element.
546 | - `:icon_class` - CSS classes for the icon SVG.
547 |
548 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
549 |
550 | # [](AshAuthentication.Phoenix.Components.OAuth2.html#summary)Summary
551 |
552 | ## [Types](AshAuthentication.Phoenix.Components.OAuth2.html#types)
553 |
554 | [props()](AshAuthentication.Phoenix.Components.OAuth2.html#t:props/0)
555 |
556 | ## [Functions](AshAuthentication.Phoenix.Components.OAuth2.html#functions)
557 |
558 | [icon(assigns)](AshAuthentication.Phoenix.Components.OAuth2.html#icon/1)
559 |
560 | # [](AshAuthentication.Phoenix.Components.OAuth2.html#types)Types
561 |
562 | [](AshAuthentication.Phoenix.Components.OAuth2.html#t:props/0)
563 |
564 | # props()
565 |
566 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/oauth2.ex#L32)
567 |
568 | ```
569 | @type props() :: %{
570 | :strategy => AshAuthentication.Strategy.t(),
571 | optional(:auth_routes_prefix) => String.t(),
572 | optional(:overrides) => [module()],
573 | optional(:gettext_fn) => {module(), atom()}
574 | }
575 | ```
576 |
577 | # [](AshAuthentication.Phoenix.Components.OAuth2.html#functions)Functions
578 |
579 | [](AshAuthentication.Phoenix.Components.OAuth2.html#icon/1)
580 |
581 | # icon(assigns)
582 |
583 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/oauth2.ex#L63)
584 |
585 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
586 |
587 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
588 | [ash\_authentication\_phoenix](readme.html)
589 |
590 | v2.4.5
591 |
592 | - Pages
593 | - Modules
594 | - Mix Tasks
595 |
596 | <!--THE END-->
597 |
598 | <!--THE END-->
599 |
600 | <!--THE END-->
601 |
602 | Search documentation of ash\_authentication\_phoenix
603 |
604 | Settings
605 |
606 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Password (ash\_authentication\_phoenix v2.4.5)
607 |
608 | Generates sign in, registration and reset forms for a resource.
609 |
610 | ## [](AshAuthentication.Phoenix.Components.Password.html#module-component-hierarchy)Component hierarchy
611 |
612 | This is the top-most strategy-specific component, nested below [`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html).
613 |
614 | Children:
615 |
616 | - [`AshAuthentication.Phoenix.Components.Password.SignInForm`](AshAuthentication.Phoenix.Components.Password.SignInForm.html)
617 | - [`AshAuthentication.Phoenix.Components.Password.RegisterForm`](AshAuthentication.Phoenix.Components.Password.RegisterForm.html)
618 | - [`AshAuthentication.Phoenix.Components.Password.ResetForm`](AshAuthentication.Phoenix.Components.Password.ResetForm.html)
619 |
620 | ## [](AshAuthentication.Phoenix.Components.Password.html#module-props)Props
621 |
622 | - `strategy` - The strategy configuration as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
623 | - `overrides` - A list of override modules.
624 | - `gettext_fn` - Optional text translation function.
625 |
626 | ## [](AshAuthentication.Phoenix.Components.Password.html#module-slots)Slots
627 |
628 | - `sign_in_extra` - rendered inside the sign-in form with the form passed as a slot argument.
629 | - `register_extra` - rendered inside the registration form with the form passed as a slot argument.
630 | - `reset_extra` - rendered inside the reset form with the form passed as a slot argument.
631 | - `path` - used as the base for links to other pages.
632 | - `reset_path` - the path to use for reset links.
633 | - `register_path` - the path to use for register links.
634 |
635 | ```
636 | <.live_component
637 | module={AshAuthentication.Phoenix.Components.Password}
638 | strategy={AshAuthentication.Info.strategy!(Example.User, :password)}
639 | id="user-with-password"
640 | socket={@socket}
641 | overrides={[AshAuthentication.Phoenix.Overrides.Default]}>
642 |
643 | <:sign_in_extra :let={form}>
644 | <.input field={form[:capcha]} />
645 | </:sign_in_extra>
646 |
647 | <:register_extra :let={form}>
648 | <.input field={form[:name]} />
649 | </:register_extra>
650 |
651 | <:reset_extra :let={form}>
652 | <.input field={form[:capcha]} />
653 | </:reset_extra>
654 | </.live_component>
655 | ```
656 |
657 | ## [](AshAuthentication.Phoenix.Components.Password.html#module-overrides)Overrides
658 |
659 | This component provides the following overrides:
660 |
661 | - `:root_class` - CSS class for the root `div` element.
662 | - `:hide_class` - CSS class to apply to hide an element.
663 | - `:show_first` - The form to show on first load. Either `:sign_in` or `:register`. Only relevant if paths aren't set for them in the router.
664 | - `:interstitial_class` - CSS class for the `div` element between the form and the button.
665 | - `:sign_in_toggle_text` - Toggle text to display when the sign in form is not showing (or `nil` to disable).
666 | - `:register_toggle_text` - Toggle text to display when the register form is not showing (or `nil` to disable).
667 | - `:reset_toggle_text` - Toggle text to display when the reset form is not showing (or `nil` to disable).
668 | - `:toggler_class` - CSS class for the toggler `a` element.
669 | - `:slot_class` - CSS class for the `div` surrounding the slot.
670 |
671 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
672 |
673 | # [](AshAuthentication.Phoenix.Components.Password.html#summary)Summary
674 |
675 | ## [Types](AshAuthentication.Phoenix.Components.Password.html#types)
676 |
677 | [props()](AshAuthentication.Phoenix.Components.Password.html#t:props/0)
678 |
679 | # [](AshAuthentication.Phoenix.Components.Password.html#types)Types
680 |
681 | [](AshAuthentication.Phoenix.Components.Password.html#t:props/0)
682 |
683 | # props()
684 |
685 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password.ex#L82)
686 |
687 | ```
688 | @type props() :: %{
689 | :strategy => AshAuthentication.Strategy.t(),
690 | optional(:live_action) => :sign_in | :register,
691 | optional(:path) => String.t(),
692 | optional(:current_tenant) => String.t(),
693 | optional(:context) => map(),
694 | optional(:overrides) => [module()],
695 | optional(:gettext_fn) => {module(), atom()}
696 | }
697 | ```
698 |
699 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
700 |
701 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
702 | [ash\_authentication\_phoenix](readme.html)
703 |
704 | v2.4.5
705 |
706 | - Pages
707 | - Modules
708 | - Mix Tasks
709 |
710 | <!--THE END-->
711 |
712 | <!--THE END-->
713 |
714 | <!--THE END-->
715 |
716 | Search documentation of ash\_authentication\_phoenix
717 |
718 | Settings
719 |
720 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Password.Input (ash\_authentication\_phoenix v2.4.5)
721 |
722 | Function components for dealing with form input during password authentication.
723 |
724 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#module-component-hierarchy)Component hierarchy
725 |
726 | These function components are consumed by [`AshAuthentication.Phoenix.Components.Password.SignInForm`](AshAuthentication.Phoenix.Components.Password.SignInForm.html), [`AshAuthentication.Phoenix.Components.Password.RegisterForm`](AshAuthentication.Phoenix.Components.Password.RegisterForm.html) and `AshAuthentication.Phoenix.Components.ResetForm`.
727 |
728 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#module-overrides)Overrides
729 |
730 | This component provides the following overrides:
731 |
732 | - `:label_class` - CSS class for `label` elements.
733 | - `:field_class` - CSS class for `div` elements surrounding the fields.
734 | - `:input_class` - CSS class for text/password `input` elements.
735 | - `:identity_input_label` - Label for identity field.
736 | - `:identity_input_placeholder` - Placeholder for identity field.
737 | - `:password_input_label` - Label for password field.
738 | - `:password_confirmation_input_label` - Label for password confirmation field.
739 | - `:input_class_with_error` - CSS class for text/password `input` elements when there is a validation error.
740 | - `:submit_class` - CSS class for the form submit `input` element.
741 | - `:error_ul` - CSS class for the `ul` element on error lists.
742 | - `:error_li` - CSS class for the `li` elements on error lists.
743 | - `:input_debounce` - Number of milliseconds to debounce input by (or `nil` to disable).
744 |
745 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
746 |
747 | # [](AshAuthentication.Phoenix.Components.Password.Input.html#summary)Summary
748 |
749 | ## [Functions](AshAuthentication.Phoenix.Components.Password.Input.html#functions)
750 |
751 | [error(assigns)](AshAuthentication.Phoenix.Components.Password.Input.html#error/1)
752 |
753 | Generate a list of errors for a field (if there are any).
754 |
755 | [identity\_field(assigns)](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
756 |
757 | Generate a form field for the configured identity field.
758 |
759 | [password\_confirmation\_field(assigns)](AshAuthentication.Phoenix.Components.Password.Input.html#password_confirmation_field/1)
760 |
761 | Generate a form field for the configured password confirmation entry field.
762 |
763 | [password\_field(assigns)](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
764 |
765 | Generate a form field for the configured password entry field.
766 |
767 | [submit(assigns)](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
768 |
769 | Generate an form submit button.
770 |
771 | # [](AshAuthentication.Phoenix.Components.Password.Input.html#functions)Functions
772 |
773 | [](AshAuthentication.Phoenix.Components.Password.Input.html#error/1)
774 |
775 | # error(assigns)
776 |
777 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L302)
778 |
779 | ```
780 | @spec error(%{
781 | :socket => Phoenix.LiveView.Socket.t(),
782 | :form => AshPhoenix.Form.t(),
783 | :field => atom(),
784 | optional(:field_label) => String.Chars.t(),
785 | optional(:errors) => [{atom(), String.t()}],
786 | optional(:gettext_fn) => {module(), atom()}
787 | }) :: Phoenix.LiveView.Rendered.t() | no_return()
788 | ```
789 |
790 | Generate a list of errors for a field (if there are any).
791 |
792 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#error/1-props)Props
793 |
794 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
795 | - `form` - An [`AshPhoenix.Form`](../ash_phoenix/2.1.14/AshPhoenix.Form.html). Required.
796 | - `field` - The field for which to retrieve the errors. Required.
797 | - `overrides` - A list of override modules.
798 | - `gettext_fn` - Optional text translation function.
799 |
800 | [](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
801 |
802 | # identity\_field(assigns)
803 |
804 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L64)
805 |
806 | ```
807 | @spec identity_field(%{
808 | :socket => Phoenix.LiveView.Socket.t(),
809 | :strategy => AshAuthentication.Strategy.t(),
810 | :form => AshPhoenix.Form.t(),
811 | optional(:input_type) => :text | :email,
812 | optional(:overrides) => [module()],
813 | optional(:gettext_fn) => {module(), atom()}
814 | }) :: Phoenix.LiveView.Rendered.t() | no_return()
815 | ```
816 |
817 | Generate a form field for the configured identity field.
818 |
819 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1-props)Props
820 |
821 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
822 | - `strategy` - The configuration map as per [`AshAuthentication.authenticated_resources/1`](../ash_authentication/4.4.3/AshAuthentication.html#authenticated_resources/1). Required.
823 | - `form` - An [`AshPhoenix.Form`](../ash_phoenix/2.1.14/AshPhoenix.Form.html). Required.
824 | - `input_type` - Either `:text` or `:email`. If not set it will try and guess based on the name of the identity field.
825 | - `overrides` - A list of override modules.
826 | - `gettext_fn` - Optional text translation function.
827 |
828 | [](AshAuthentication.Phoenix.Components.Password.Input.html#password_confirmation_field/1)
829 |
830 | # password\_confirmation\_field(assigns)
831 |
832 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L177)
833 |
834 | ```
835 | @spec password_confirmation_field(%{
836 | :socket => Phoenix.LiveView.Socket.t(),
837 | :strategy => AshAuthentication.Strategy.t(),
838 | :form => AshPhoenix.Form.t(),
839 | optional(:overrides) => [module()],
840 | optional(:gettext_fn) => {module(), atom()}
841 | }) :: Phoenix.LiveView.Rendered.t() | no_return()
842 | ```
843 |
844 | Generate a form field for the configured password confirmation entry field.
845 |
846 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#password_confirmation_field/1-props)Props
847 |
848 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
849 | - `strategy` - The configuration map as per [`AshAuthentication.authenticated_resources/1`](../ash_authentication/4.4.3/AshAuthentication.html#authenticated_resources/1). Required.
850 | - `form` - An [`AshPhoenix.Form`](../ash_phoenix/2.1.14/AshPhoenix.Form.html). Required.
851 | - `overrides` - A list of override modules.
852 | - `gettext_fn` - Optional text translation function.
853 |
854 | [](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
855 |
856 | # password\_field(assigns)
857 |
858 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L126)
859 |
860 | ```
861 | @spec password_field(%{
862 | :socket => Phoenix.LiveView.Socket.t(),
863 | :strategy => AshAuthentication.Strategy.t(),
864 | :form => AshPhoenix.Form.t(),
865 | optional(:overrides) => [module()],
866 | optional(:gettext_fn) => {module(), atom()}
867 | }) :: Phoenix.LiveView.Rendered.t() | no_return()
868 | ```
869 |
870 | Generate a form field for the configured password entry field.
871 |
872 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1-props)Props
873 |
874 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
875 | - `strategy` - The configuration map as per [`AshAuthentication.authenticated_resources/1`](../ash_authentication/4.4.3/AshAuthentication.html#authenticated_resources/1). Required.
876 | - `form` - An [`AshPhoenix.Form`](../ash_phoenix/2.1.14/AshPhoenix.Form.html). Required.
877 | - `overrides` - A list of override modules.
878 | - `gettext_fn` - Optional text translation function.
879 |
880 | [](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
881 |
882 | # submit(assigns)
883 |
884 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/input.ex#L236)
885 |
886 | ```
887 | @spec submit(%{
888 | :socket => Phoenix.LiveView.Socket.t(),
889 | :strategy => AshAuthentication.Strategy.t(),
890 | :form => AshPhoenix.Form.t(),
891 | :action => :sign_in | :register | :request_reset | :reset,
892 | optional(:label) => String.t(),
893 | optional(:overrides) => [module()],
894 | optional(:gettext_fn) => {module(), atom()}
895 | }) :: Phoenix.LiveView.Rendered.t() | no_return()
896 | ```
897 |
898 | Generate an form submit button.
899 |
900 | ## [](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1-props)Props
901 |
902 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
903 | - `strategy` - The configuration map as per [`AshAuthentication.authenticated_resources/1`](../ash_authentication/4.4.3/AshAuthentication.html#authenticated_resources/1). Required.
904 | - `form` - An [`AshPhoenix.Form`](../ash_phoenix/2.1.14/AshPhoenix.Form.html). Required.
905 | - `action` - Either `:sign_in`, `:register`, `:request_reset` or `:reset`. Required.
906 | - `label` - The text to show in the submit label. Generated from the configured action name (via [`Phoenix.Naming.humanize/1`](../phoenix/1.7.18/Phoenix.Naming.html#humanize/1)) if not supplied.
907 | - `overrides` - A list of override modules.
908 | - `gettext_fn` - Optional text translation function.
909 |
910 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
911 |
912 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
913 | [ash\_authentication\_phoenix](readme.html)
914 |
915 | v2.4.5
916 |
917 | - Pages
918 | - Modules
919 | - Mix Tasks
920 |
921 | <!--THE END-->
922 |
923 | <!--THE END-->
924 |
925 | <!--THE END-->
926 |
927 | Search documentation of ash\_authentication\_phoenix
928 |
929 | Settings
930 |
931 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/register_form.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Password.RegisterForm (ash\_authentication\_phoenix v2.4.5)
932 |
933 | Generates a default registration form.
934 |
935 | ## [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#module-component-hierarchy)Component hierarchy
936 |
937 | This is a child of [`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html).
938 |
939 | Children:
940 |
941 | - [`AshAuthentication.Phoenix.Components.Password.Input.identity_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
942 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
943 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_confirmation_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_confirmation_field/1)
944 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
945 |
946 | ## [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#module-props)Props
947 |
948 | - `strategy` - The strategy configuration as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
949 | - `socket` - Needed to infer the otp-app from the Phoenix endpoint.
950 | - `overrides` - A list of override modules.
951 | - `gettext_fn` - Optional text translation function.
952 |
953 | ## [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#module-overrides)Overrides
954 |
955 | This component provides the following overrides:
956 |
957 | - `:root_class` - CSS class for the root `div` element.
958 | - `:label_class` - CSS class for the `h2` element.
959 | - `:form_class` - CSS class for the `form` element.
960 | - `:disable_button_text` - Text for the submit button when the request is happening.
961 | - `:slot_class` - CSS class for the `div` surrounding the slot.
962 | - `:button_text` - Text for the submit button.
963 |
964 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
965 |
966 | # [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#summary)Summary
967 |
968 | ## [Types](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#types)
969 |
970 | [props()](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#t:props/0)
971 |
972 | # [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#types)Types
973 |
974 | [](AshAuthentication.Phoenix.Components.Password.RegisterForm.html#t:props/0)
975 |
976 | # props()
977 |
978 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/register_form.ex#L45)
979 |
980 | ```
981 | @type props() :: %{
982 | :strategy => AshAuthentication.Strategy.t(),
983 | optional(:live_action) => :sign_in | :register,
984 | optional(:current_tenant) => String.t(),
985 | optional(:context) => map(),
986 | optional(:auth_routes_prefix) => String.t(),
987 | optional(:overrides) => [module()],
988 | optional(:gettext_fn) => {module(), atom()}
989 | }
990 | ```
991 |
992 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
993 |
994 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
995 | [ash\_authentication\_phoenix](readme.html)
996 |
997 | v2.4.5
998 |
999 | - Pages
1000 | - Modules
1001 | - Mix Tasks
1002 |
1003 | <!--THE END-->
1004 |
1005 | <!--THE END-->
1006 |
1007 | <!--THE END-->
1008 |
1009 | Search documentation of ash\_authentication\_phoenix
1010 |
1011 | Settings
1012 |
1013 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/reset_form.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Password.ResetForm (ash\_authentication\_phoenix v2.4.5)
1014 |
1015 | Generates a default password reset form.
1016 |
1017 | ## [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#module-component-hierarchy)Component hierarchy
1018 |
1019 | This is a child of [`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html).
1020 |
1021 | Children:
1022 |
1023 | - [`AshAuthentication.Phoenix.Components.Password.Input.identity_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
1024 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
1025 |
1026 | ## [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#module-props)Props
1027 |
1028 | - `strategy` - The configuration map as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
1029 | - `label` - The text to show in the submit label. Generated from the configured action name (via [`Phoenix.Naming.humanize/1`](../phoenix/1.7.18/Phoenix.Naming.html#humanize/1)) if not supplied. Set to `false` to disable.
1030 | - `overrides` - A list of override modules.
1031 | - `gettext_fn` - Optional text translation function.
1032 |
1033 | ## [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#module-overrides)Overrides
1034 |
1035 | This component provides the following overrides:
1036 |
1037 | - `:root_class` - CSS class for the root `div` element.
1038 | - `:label_class` - CSS class for the `h2` element.
1039 | - `:form_class` - CSS class for the `form` element.
1040 | - `:disable_button_text` - Text for the submit button when the request is happening.
1041 | - `:slot_class` - CSS class for the `div` surrounding the slot.
1042 | - `:button_text` - Tex for the submit button.
1043 | - `:reset_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.
1044 |
1045 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
1046 |
1047 | # [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#summary)Summary
1048 |
1049 | ## [Types](AshAuthentication.Phoenix.Components.Password.ResetForm.html#types)
1050 |
1051 | [props()](AshAuthentication.Phoenix.Components.Password.ResetForm.html#t:props/0)
1052 |
1053 | # [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#types)Types
1054 |
1055 | [](AshAuthentication.Phoenix.Components.Password.ResetForm.html#t:props/0)
1056 |
1057 | # props()
1058 |
1059 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/reset_form.ex#L46)
1060 |
1061 | ```
1062 | @type props() :: %{
1063 | :strategy => AshAuthentication.Strategy.t(),
1064 | optional(:label) => String.t() | false,
1065 | optional(:current_tenant) => String.t(),
1066 | optional(:context) => map(),
1067 | optional(:auth_routes_prefix) => String.t(),
1068 | optional(:overrides) => [module()],
1069 | optional(:gettext_fn) => {module(), atom()}
1070 | }
1071 | ```
1072 |
1073 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1074 |
1075 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1076 | [ash\_authentication\_phoenix](readme.html)
1077 |
1078 | v2.4.5
1079 |
1080 | - Pages
1081 | - Modules
1082 | - Mix Tasks
1083 |
1084 | <!--THE END-->
1085 |
1086 | <!--THE END-->
1087 |
1088 | <!--THE END-->
1089 |
1090 | Search documentation of ash\_authentication\_phoenix
1091 |
1092 | Settings
1093 |
1094 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/sign_in_form.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Password.SignInForm (ash\_authentication\_phoenix v2.4.5)
1095 |
1096 | Generates a default sign in form.
1097 |
1098 | ## [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#module-component-hierarchy)Component hierarchy
1099 |
1100 | This is a child of [`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html).
1101 |
1102 | Children:
1103 |
1104 | - [`AshAuthentication.Phoenix.Components.Password.Input.identity_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
1105 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
1106 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
1107 |
1108 | ## [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#module-props)Props
1109 |
1110 | - `strategy` - The configuration map as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
1111 | - `label` - The text to show in the submit label. Generated from the configured action name (via [`Phoenix.Naming.humanize/1`](../phoenix/1.7.18/Phoenix.Naming.html#humanize/1)) if not supplied. Set to `false` to disable.
1112 | - `overrides` - A list of override modules.
1113 | - `gettext_fn` - Optional text translation function.
1114 |
1115 | ## [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#module-overrides)Overrides
1116 |
1117 | This component provides the following overrides:
1118 |
1119 | - `:root_class` - CSS class for the root `div` element.
1120 | - `:label_class` - CSS class for the `h2` element.
1121 | - `:form_class` - CSS class for the `form` element.
1122 | - `:disable_button_text` - Text for the submit button when the request is happening.
1123 | - `:slot_class` - CSS class for the `div` surrounding the slot.
1124 | - `:button_text` - Text for the submit button.
1125 |
1126 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
1127 |
1128 | # [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#summary)Summary
1129 |
1130 | ## [Types](AshAuthentication.Phoenix.Components.Password.SignInForm.html#types)
1131 |
1132 | [props()](AshAuthentication.Phoenix.Components.Password.SignInForm.html#t:props/0)
1133 |
1134 | # [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#types)Types
1135 |
1136 | [](AshAuthentication.Phoenix.Components.Password.SignInForm.html#t:props/0)
1137 |
1138 | # props()
1139 |
1140 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/password/sign_in_form.ex#L47)
1141 |
1142 | ```
1143 | @type props() :: %{
1144 | :strategy => AshAuthentication.Strategy.t(),
1145 | optional(:label) => String.t() | false,
1146 | optional(:current_tenant) => String.t(),
1147 | optional(:context) => map(),
1148 | optional(:auth_routes_prefix) => String.t(),
1149 | optional(:overrides) => [module()],
1150 | optional(:gettext_fn) => {module(), atom()}
1151 | }
1152 | ```
1153 |
1154 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1155 |
1156 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1157 | [ash\_authentication\_phoenix](readme.html)
1158 |
1159 | v2.4.5
1160 |
1161 | - Pages
1162 | - Modules
1163 | - Mix Tasks
1164 |
1165 | <!--THE END-->
1166 |
1167 | <!--THE END-->
1168 |
1169 | <!--THE END-->
1170 |
1171 | Search documentation of ash\_authentication\_phoenix
1172 |
1173 | Settings
1174 |
1175 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/reset/form.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Reset.Form (ash\_authentication\_phoenix v2.4.5)
1176 |
1177 | Generates a default password reset form.
1178 |
1179 | ## [](AshAuthentication.Phoenix.Components.Reset.Form.html#module-component-hierarchy)Component hierarchy
1180 |
1181 | This is a child of [`AshAuthentication.Phoenix.Components.Reset`](AshAuthentication.Phoenix.Components.Reset.html).
1182 |
1183 | Children:
1184 |
1185 | - [`AshAuthentication.Phoenix.Components.Password.Input.identity_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#identity_field/1)
1186 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
1187 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
1188 | - [`AshAuthentication.Phoenix.Components.Password.Input.error/1`](AshAuthentication.Phoenix.Components.Password.Input.html#error/1)
1189 |
1190 | ## [](AshAuthentication.Phoenix.Components.Reset.Form.html#module-props)Props
1191 |
1192 | - `token` - The reset token.
1193 | - `socket` - Phoenix LiveView socket. This is needed to be able to retrieve the correct CSS configuration. Required.
1194 | - `strategy` - The configuration map as per [`AshAuthentication.Info.strategy/2`](../ash_authentication/4.4.3/AshAuthentication.Info.html#strategy/2). Required.
1195 | - `label` - The text to show in the submit label. Generated from the configured action name (via [`Phoenix.Naming.humanize/1`](../phoenix/1.7.18/Phoenix.Naming.html#humanize/1)) if not supplied. Set to `false` to disable.
1196 | - `overrides` - A list of override modules.
1197 | - `gettext_fn` - Optional text translation function.
1198 |
1199 | ## [](AshAuthentication.Phoenix.Components.Reset.Form.html#module-overrides)Overrides
1200 |
1201 | This component provides the following overrides:
1202 |
1203 | - `:root_class` - CSS class for the root `div` element.
1204 | - `:label_class` - CSS class for the `h2` element.
1205 | - `:form_class` - CSS class for the `form` element.
1206 | - `:spacer_class` - CSS classes for space between the password input and submit elements.
1207 | - `:disable_button_text` - Text for the submit button when the request is happening.
1208 |
1209 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
1210 |
1211 | # [](AshAuthentication.Phoenix.Components.Reset.Form.html#summary)Summary
1212 |
1213 | ## [Types](AshAuthentication.Phoenix.Components.Reset.Form.html#types)
1214 |
1215 | [props()](AshAuthentication.Phoenix.Components.Reset.Form.html#t:props/0)
1216 |
1217 | # [](AshAuthentication.Phoenix.Components.Reset.Form.html#types)Types
1218 |
1219 | [](AshAuthentication.Phoenix.Components.Reset.Form.html#t:props/0)
1220 |
1221 | # props()
1222 |
1223 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/reset/form.ex#L47)
1224 |
1225 | ```
1226 | @type props() :: %{
1227 | :socket => Phoenix.LiveView.Socket.t(),
1228 | :strategy => AshAuthentication.Strategy.t(),
1229 | :token => String.t(),
1230 | optional(:label) => String.t() | false,
1231 | optional(:auth_routes_prefix) => String.t(),
1232 | optional(:overrides) => [module()],
1233 | optional(:gettext_fn) => {module(), atom()}
1234 | }
1235 | ```
1236 |
1237 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1238 |
1239 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1240 | [ash\_authentication\_phoenix](readme.html)
1241 |
1242 | v2.4.5
1243 |
1244 | - Pages
1245 | - Modules
1246 | - Mix Tasks
1247 |
1248 | <!--THE END-->
1249 |
1250 | <!--THE END-->
1251 |
1252 | <!--THE END-->
1253 |
1254 | Search documentation of ash\_authentication\_phoenix
1255 |
1256 | Settings
1257 |
1258 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/reset.ex#L1 "View Source") AshAuthentication.Phoenix.Components.Reset (ash\_authentication\_phoenix v2.4.5)
1259 |
1260 | Renders a password-reset form.
1261 |
1262 | ## [](AshAuthentication.Phoenix.Components.Reset.html#module-component-hierarchy)Component hierarchy
1263 |
1264 | Children:
1265 |
1266 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_field/1)
1267 | - [`AshAuthentication.Phoenix.Components.Password.Input.password_confirmation_field/1`](AshAuthentication.Phoenix.Components.Password.Input.html#password_confirmation_field/1)
1268 | - [`AshAuthentication.Phoenix.Components.Password.Input.submit/1`](AshAuthentication.Phoenix.Components.Password.Input.html#submit/1)
1269 |
1270 | ## [](AshAuthentication.Phoenix.Components.Reset.html#module-props)Props
1271 |
1272 | - `token` - The reset token.
1273 | - `overrides` - A list of override modules.
1274 | - `gettext_fn` - Optional text translation function.
1275 | - `otp_app` - The otp app to look for authenticated resources in
1276 |
1277 | ## [](AshAuthentication.Phoenix.Components.Reset.html#module-overrides)Overrides
1278 |
1279 | This component provides the following overrides:
1280 |
1281 | - `:root_class` - CSS class for the root `div` element.
1282 | - `:strategy_class` - CSS class for a `div` surrounding each strategy component.
1283 | - `:show_banner` - Whether or not to show the banner.
1284 |
1285 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
1286 |
1287 | # [](AshAuthentication.Phoenix.Components.Reset.html#summary)Summary
1288 |
1289 | ## [Types](AshAuthentication.Phoenix.Components.Reset.html#types)
1290 |
1291 | [props()](AshAuthentication.Phoenix.Components.Reset.html#t:props/0)
1292 |
1293 | # [](AshAuthentication.Phoenix.Components.Reset.html#types)Types
1294 |
1295 | [](AshAuthentication.Phoenix.Components.Reset.html#t:props/0)
1296 |
1297 | # props()
1298 |
1299 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/reset.ex#L33)
1300 |
1301 | ```
1302 | @type props() :: %{
1303 | :token => String.t(),
1304 | optional(:overrides) => [module()],
1305 | optional(:gettext_fn) => {module(), atom()}
1306 | }
1307 | ```
1308 |
1309 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1310 |
1311 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1312 | [ash\_authentication\_phoenix](readme.html)
1313 |
1314 | v2.4.5
1315 |
1316 | - Pages
1317 | - Modules
1318 | - Mix Tasks
1319 |
1320 | <!--THE END-->
1321 |
1322 | <!--THE END-->
1323 |
1324 | <!--THE END-->
1325 |
1326 | Search documentation of ash\_authentication\_phoenix
1327 |
1328 | Settings
1329 |
1330 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/sign_in.ex#L1 "View Source") AshAuthentication.Phoenix.Components.SignIn (ash\_authentication\_phoenix v2.4.5)
1331 |
1332 | Renders sign in mark-up for an authenticated resource.
1333 |
1334 | This means that it will render sign-in UI for all of the authentication strategies for a resource.
1335 |
1336 | For each strategy configured on the resource a component name is inferred (e.g. [`AshAuthentication.Strategy.Password`](../ash_authentication/4.4.3/AshAuthentication.Strategy.Password.html) becomes [`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html)) and is rendered into the output.
1337 |
1338 | ## [](AshAuthentication.Phoenix.Components.SignIn.html#module-component-hierarchy)Component hierarchy
1339 |
1340 | This is the top-most authentication component.
1341 |
1342 | Children:
1343 |
1344 | - [`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html).
1345 | - [`AshAuthentication.Phoenix.Components.OAuth2`](AshAuthentication.Phoenix.Components.OAuth2.html).
1346 |
1347 | ## [](AshAuthentication.Phoenix.Components.SignIn.html#module-overrides)Overrides
1348 |
1349 | This component provides the following overrides:
1350 |
1351 | - `:root_class` - CSS class for the root `div` element.
1352 | - `:strategy_class` - CSS class for a `div` surrounding each strategy component.
1353 | - `:show_banner` - Whether or not to show the banner.
1354 | - `:authentication_error_container_class` - CSS class for the container for the text of the authentication error.
1355 | - `:authentication_error_text_class` - CSS class for the authentication error text.
1356 |
1357 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
1358 |
1359 | ## [](AshAuthentication.Phoenix.Components.SignIn.html#module-props)Props
1360 |
1361 | - `otp_app` - The otp app to look for authenticated resources in
1362 | - `live_action` - The live\_action being routed to
1363 | - `path` - The path to use as the base for links
1364 | - `reset_path` - The path to use for reset links
1365 | - `register_path` - The path to use for register links
1366 | - `overrides` - A list of override modules.
1367 | - `gettext_fn` - Optional text translation function.
1368 |
1369 | # [](AshAuthentication.Phoenix.Components.SignIn.html#summary)Summary
1370 |
1371 | ## [Types](AshAuthentication.Phoenix.Components.SignIn.html#types)
1372 |
1373 | [props()](AshAuthentication.Phoenix.Components.SignIn.html#t:props/0)
1374 |
1375 | # [](AshAuthentication.Phoenix.Components.SignIn.html#types)Types
1376 |
1377 | [](AshAuthentication.Phoenix.Components.SignIn.html#t:props/0)
1378 |
1379 | # props()
1380 |
1381 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/components/sign_in.ex#L49)
1382 |
1383 | ```
1384 | @type props() :: %{
1385 | optional(:path) => String.t(),
1386 | optional(:reset_path) => String.t(),
1387 | optional(:register_path) => String.t(),
1388 | optional(:current_tenant) => String.t(),
1389 | optional(:context) => map(),
1390 | optional(:overrides) => [module()],
1391 | optional(:gettext_fn) => {module(), atom()}
1392 | }
1393 | ```
1394 |
1395 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1396 |
1397 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1398 | [ash\_authentication\_phoenix](readme.html)
1399 |
1400 | v2.4.5
1401 |
1402 | - Pages
1403 | - Modules
1404 | - Mix Tasks
1405 |
1406 | <!--THE END-->
1407 |
1408 | <!--THE END-->
1409 |
1410 | <!--THE END-->
1411 |
1412 | Search documentation of ash\_authentication\_phoenix
1413 |
1414 | Settings
1415 |
1416 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L1 "View Source") AshAuthentication.Phoenix.Controller behaviour (ash\_authentication\_phoenix v2.4.5)
1417 |
1418 | The authentication controller generator.
1419 |
1420 | Since authentication often requires explicit HTTP requests to do things like set cookies or return Authorization headers, use this module to create an `AuthController` in your Phoenix application.
1421 |
1422 | ## [](AshAuthentication.Phoenix.Controller.html#module-example)Example
1423 |
1424 | Handling the registration or authentication of a normal web-based user.
1425 |
1426 | ```
1427 | defmodule MyAppWeb.AuthController do
1428 | use MyAppWeb, :controller
1429 | use AshAuthentication.Phoenix.Controller
1430 |
1431 | def success(conn, _activity, user, _token) do
1432 | conn
1433 | |> store_in_session(user)
1434 | |> assign(:current_user, user)
1435 | |> redirect(to: Routes.page_path(conn, :index))
1436 | end
1437 |
1438 | def failure(conn, _activity, _reason) do
1439 | conn
1440 | |> put_status(401)
1441 | |> render("failure.html")
1442 | end
1443 |
1444 | def sign_out(conn, _params) do
1445 | conn
1446 | |> clear_session()
1447 | |> render("sign_out.html")
1448 | end
1449 | end
1450 | ```
1451 |
1452 | Handling registration or authentication of an API user.
1453 |
1454 | ```
1455 | defmodule MyAppWeb.ApiAuthController do
1456 | use MyAppWeb, :controller
1457 | use AshAuthentication.Phoenix.Controller
1458 | alias AshAuthentication.TokenRevocation
1459 |
1460 | def success(conn, _activity, _user, token) do
1461 | conn
1462 | |> put_status(200)
1463 | |> json(%{
1464 | authentication: %{
1465 | status: :success,
1466 | bearer: token}
1467 | })
1468 | end
1469 |
1470 | def failure(conn, _activity, _reason) do
1471 | conn
1472 | |> put_status(401)
1473 | |> json(%{
1474 | authentication: %{
1475 | status: :failed
1476 | }
1477 | })
1478 | end
1479 |
1480 | def sign_out(conn, _params) do
1481 | conn
1482 | |> revoke_bearer_tokens()
1483 | |> json(%{
1484 | status: :ok
1485 | })
1486 | end
1487 | end
1488 | ```
1489 |
1490 | # [](AshAuthentication.Phoenix.Controller.html#summary)Summary
1491 |
1492 | ## [Types](AshAuthentication.Phoenix.Controller.html#types)
1493 |
1494 | [activity()](AshAuthentication.Phoenix.Controller.html#t:activity/0)
1495 |
1496 | [t()](AshAuthentication.Phoenix.Controller.html#t:t/0)
1497 |
1498 | [token()](AshAuthentication.Phoenix.Controller.html#t:token/0)
1499 |
1500 | [user()](AshAuthentication.Phoenix.Controller.html#t:user/0)
1501 |
1502 | ## [Callbacks](AshAuthentication.Phoenix.Controller.html#callbacks)
1503 |
1504 | [failure(t, activity, reason)](AshAuthentication.Phoenix.Controller.html#c:failure/3)
1505 |
1506 | Called when authentication fails.
1507 |
1508 | [sign\_out(t, params)](AshAuthentication.Phoenix.Controller.html#c:sign_out/2)
1509 |
1510 | Called when a request to sign out is received.
1511 |
1512 | [success(t, activity, user, token)](AshAuthentication.Phoenix.Controller.html#c:success/4)
1513 |
1514 | Called when authentication (or registration, depending on the provider) has been successful.
1515 |
1516 | # [](AshAuthentication.Phoenix.Controller.html#types)Types
1517 |
1518 | [](AshAuthentication.Phoenix.Controller.html#t:activity/0)
1519 |
1520 | # activity()
1521 |
1522 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L84)
1523 |
1524 | ```
1525 | @type activity() :: {strategy_name :: atom(), phase :: atom()}
1526 | ```
1527 |
1528 | [](AshAuthentication.Phoenix.Controller.html#t:t/0)
1529 |
1530 | # t()
1531 |
1532 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L82)
1533 |
1534 | ```
1535 | @type t() :: module()
1536 | ```
1537 |
1538 | [](AshAuthentication.Phoenix.Controller.html#t:token/0)
1539 |
1540 | # token()
1541 |
1542 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L86)
1543 |
1544 | ```
1545 | @type token() :: String.t() | nil
1546 | ```
1547 |
1548 | [](AshAuthentication.Phoenix.Controller.html#t:user/0)
1549 |
1550 | # user()
1551 |
1552 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L85)
1553 |
1554 | ```
1555 | @type user() :: Ash.Resource.record() | nil
1556 | ```
1557 |
1558 | # [](AshAuthentication.Phoenix.Controller.html#callbacks)Callbacks
1559 |
1560 | [](AshAuthentication.Phoenix.Controller.html#c:failure/3)
1561 |
1562 | # failure(t, activity, reason)
1563 |
1564 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L96)
1565 |
1566 | ```
1567 | @callback failure(Plug.Conn.t(), activity(), reason :: any()) :: Plug.Conn.t()
1568 | ```
1569 |
1570 | Called when authentication fails.
1571 |
1572 | [](AshAuthentication.Phoenix.Controller.html#c:sign_out/2)
1573 |
1574 | # sign\_out(t, params)
1575 |
1576 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L101)
1577 |
1578 | ```
1579 | @callback sign_out(Plug.Conn.t(), params :: map()) :: Plug.Conn.t()
1580 | ```
1581 |
1582 | Called when a request to sign out is received.
1583 |
1584 | [](AshAuthentication.Phoenix.Controller.html#c:success/4)
1585 |
1586 | # success(t, activity, user, token)
1587 |
1588 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/controller.ex#L91)
1589 |
1590 | ```
1591 | @callback success(Plug.Conn.t(), activity(), user(), token()) :: Plug.Conn.t()
1592 | ```
1593 |
1594 | Called when authentication (or registration, depending on the provider) has been successful.
1595 |
1596 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1597 |
1598 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1599 | [ash\_authentication\_phoenix](readme.html)
1600 |
1601 | v2.4.5
1602 |
1603 | - Pages
1604 | - Modules
1605 | - Mix Tasks
1606 |
1607 | <!--THE END-->
1608 |
1609 | <!--THE END-->
1610 |
1611 | <!--THE END-->
1612 |
1613 | Search documentation of ash\_authentication\_phoenix
1614 |
1615 | Settings
1616 |
1617 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix.ex#L1 "View Source") AshAuthentication.Phoenix (ash\_authentication\_phoenix v2.4.5)
1618 |
1619 | Welcome to `AshAuthentication.Pheonix`.
1620 |
1621 | The `ash_authentication_phoenix` package extends [`ash_authentication`](https://github.com/team-alembic/ash_authentication) by adding router helpers, plugs and behaviours that makes adding authentication to an existing Ash-based Phoenix application dead easy.
1622 |
1623 | ## [](AshAuthentication.Phoenix.html#module-where-to-start)Where to start.
1624 |
1625 | Presuming that you already have [Phoenix](https://phoenixframework.org/), [Ash](https://ash-hq.org/) and [AshAuthentication](https://github.com/team-alembic/ash_authentication) installed and configured, start by adding plugs and routes to your router using [`AshAuthentication.Phoenix.Router`](AshAuthentication.Phoenix.Router.html) and customising your sign-in page as needed.
1626 |
1627 | ### [](AshAuthentication.Phoenix.html#module-customisation)Customisation
1628 |
1629 | There are several methods of customisation available depending on the level of control you would like:
1630 |
1631 | 1. Use the generic sign-in liveview - [`AshAuthentication.Phoenix.SignInLive`](AshAuthentication.Phoenix.SignInLive.html).
1632 | 2. Apply overrides using [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) to set your own CSS classes for all components.
1633 | 3. Build your own sign-in pages using the pre-defined components.
1634 | 4. Build your own sign-in pages using the generated `auth` routes.
1635 |
1636 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1637 |
1638 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1639 | [ash\_authentication\_phoenix](readme.html)
1640 |
1641 | v2.4.5
1642 |
1643 | - Pages
1644 | - Modules
1645 | - Mix Tasks
1646 |
1647 | <!--THE END-->
1648 |
1649 | <!--THE END-->
1650 |
1651 | <!--THE END-->
1652 |
1653 | Search documentation of ash\_authentication\_phoenix
1654 |
1655 | Settings
1656 |
1657 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/live_session.ex#L1 "View Source") AshAuthentication.Phoenix.LiveSession (ash\_authentication\_phoenix v2.4.5)
1658 |
1659 | Ensures that any loaded users which are present in a conn's assigns are also present in a live view socket's assigns.
1660 |
1661 | Typical usage is via the [`ash_authentication_live_session/2`](AshAuthentication.Phoenix.LiveSession.html#ash_authentication_live_session/2) macro, but can also manually called like so:
1662 |
1663 | ```
1664 | scope "/", ExampleWeb do
1665 | pipe_through(:browser)
1666 |
1667 | live_session :authenticated, on_mount: LiveSession, session: {LiveSession, :generate_session, []} do
1668 | live "/", ExampleLive
1669 | end
1670 | end
1671 | ```
1672 |
1673 | # [](AshAuthentication.Phoenix.LiveSession.html#summary)Summary
1674 |
1675 | ## [Functions](AshAuthentication.Phoenix.LiveSession.html#functions)
1676 |
1677 | [ash\_authentication\_live\_session(session\_name \\\\ :ash\_authentication, opts \\\\ \[\], list)](AshAuthentication.Phoenix.LiveSession.html#ash_authentication_live_session/3)
1678 |
1679 | Generate a live session wherein all subject assigns are copied from the conn into the socket.
1680 |
1681 | [generate\_session(conn, otp\_app \\\\ nil, additional\_hooks \\\\ \[\])](AshAuthentication.Phoenix.LiveSession.html#generate_session/3)
1682 |
1683 | Supplements the session with any `current_X` assigns which are authenticated resource records from the conn.
1684 |
1685 | [on\_mount(arg1, params, session, socket)](AshAuthentication.Phoenix.LiveSession.html#on_mount/4)
1686 |
1687 | Inspects the incoming session for any subject\_name -> subject values and loads them into the socket's assigns.
1688 |
1689 | # [](AshAuthentication.Phoenix.LiveSession.html#functions)Functions
1690 |
1691 | [](AshAuthentication.Phoenix.LiveSession.html#ash_authentication_live_session/3)
1692 |
1693 | # ash\_authentication\_live\_session(session\_name \\\\ :ash\_authentication, opts \\\\ \[], list)
1694 |
1695 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/live_session.ex#L37)(macro)
1696 |
1697 | Generate a live session wherein all subject assigns are copied from the conn into the socket.
1698 |
1699 | Options:
1700 |
1701 | - `:otp_app` - Set the otp app in which to search for authenticated resources.
1702 |
1703 | All other options are passed through to `live_session`, but with session and on\_mount hooks added to set assigns for authenticated resources. Unlike `live_session`, this supports multiple MFAs provided for the `session` option. The produced sessions will be merged.
1704 |
1705 | [](AshAuthentication.Phoenix.LiveSession.html#generate_session/3)
1706 |
1707 | # generate\_session(conn, otp\_app \\\\ nil, additional\_hooks \\\\ \[])
1708 |
1709 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/live_session.ex#L145)
1710 |
1711 | ```
1712 | @spec generate_session(Plug.Conn.t(), atom() | [atom()], additional_hooks :: [mfa()]) ::
1713 | %{
1714 | required(String.t()) => String.t()
1715 | }
1716 | ```
1717 |
1718 | Supplements the session with any `current_X` assigns which are authenticated resource records from the conn.
1719 |
1720 | [](AshAuthentication.Phoenix.LiveSession.html#on_mount/4)
1721 |
1722 | # on\_mount(arg1, params, session, socket)
1723 |
1724 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/live_session.ex#L97)
1725 |
1726 | ```
1727 | @spec on_mount(
1728 | atom() | {:set_otp_app, atom()},
1729 | %{required(String.t()) => any()},
1730 | %{required(String.t()) => any()},
1731 | Phoenix.LiveView.Socket.t()
1732 | ) :: {:cont | :halt, Phoenix.LiveView.Socket.t()}
1733 | ```
1734 |
1735 | Inspects the incoming session for any subject\_name -> subject values and loads them into the socket's assigns.
1736 |
1737 | For example a session containing `{"user", "user?id=aa6c179c-ee75-4d49-8796-528c2981b396"}` becomes an assign called `current_user` with the loaded user as the value.
1738 |
1739 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1740 |
1741 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1742 | [ash\_authentication\_phoenix](readme.html)
1743 |
1744 | v2.4.5
1745 |
1746 | - Pages
1747 | - Modules
1748 | - Mix Tasks
1749 |
1750 | <!--THE END-->
1751 |
1752 | <!--THE END-->
1753 |
1754 | <!--THE END-->
1755 |
1756 | Search documentation of ash\_authentication\_phoenix
1757 |
1758 | Settings
1759 |
1760 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/default.ex#L1 "View Source") AshAuthentication.Phoenix.Overrides.Default (ash\_authentication\_phoenix v2.4.5)
1761 |
1762 | This is the default overrides for our component UI.
1763 |
1764 | The CSS styles are based on [TailwindCSS](https://tailwindcss.com/).
1765 |
1766 | # [](AshAuthentication.Phoenix.Overrides.Default.html#summary)Summary
1767 |
1768 | ## [Functions](AshAuthentication.Phoenix.Overrides.Default.html#functions)
1769 |
1770 | [overrides()](AshAuthentication.Phoenix.Overrides.Default.html#overrides/0)
1771 |
1772 | # [](AshAuthentication.Phoenix.Overrides.Default.html#functions)Functions
1773 |
1774 | [](AshAuthentication.Phoenix.Overrides.Default.html#overrides/0)
1775 |
1776 | # overrides()
1777 |
1778 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/default.ex#L1)
1779 |
1780 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1781 |
1782 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1783 | [ash\_authentication\_phoenix](readme.html)
1784 |
1785 | v2.4.5
1786 |
1787 | - Pages
1788 | - Modules
1789 | - Mix Tasks
1790 |
1791 | <!--THE END-->
1792 |
1793 | <!--THE END-->
1794 |
1795 | <!--THE END-->
1796 |
1797 | Search documentation of ash\_authentication\_phoenix
1798 |
1799 | Settings
1800 |
1801 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides.ex#L1 "View Source") AshAuthentication.Phoenix.Overrides (ash\_authentication\_phoenix v2.4.5)
1802 |
1803 | Behaviour for overriding component styles and attributes in your application.
1804 |
1805 | The default implementation is [`AshAuthentication.Phoenix.Overrides.Default`](AshAuthentication.Phoenix.Overrides.Default.html) which uses [TailwindCSS](https://tailwindcss.com/) to generate a fairly generic looking user interface.
1806 |
1807 | You can override this by adding your own override modules to the [`AshAuthentication.Phoenix.Router.sign_in_route/1`](AshAuthentication.Phoenix.Router.html#sign_in_route/1) macro in your router:
1808 |
1809 | ```
1810 | sign_in_route overrides: [MyAppWeb.AuthOverrides, AshAuthentication.Phoenix.Overrides.Default]
1811 | ```
1812 |
1813 | and defining `lib/my_app_web/auth_overrides.ex` within which you can set any overrides.
1814 |
1815 | The `use` macro defines overridable versions of all callbacks which return `nil`, so you only need to define the functions that you care about.
1816 |
1817 | Each of the override modules specified in the config will be called in the order that they're specified, so you can still use the defaults if you just override some properties.
1818 |
1819 | ```
1820 | defmodule MyAppWeb.AuthOverrides do
1821 | use AshAuthentication.Phoenix.Overrides
1822 | alias AshAuthentication.Phoenix.Components
1823 |
1824 | override Components.Banner do
1825 | set :image_url, "/images/sign_in_logo.png"
1826 | end
1827 | end
1828 | ```
1829 |
1830 | # [](AshAuthentication.Phoenix.Overrides.html#summary)Summary
1831 |
1832 | ## [Functions](AshAuthentication.Phoenix.Overrides.html#functions)
1833 |
1834 | [override(component, list)](AshAuthentication.Phoenix.Overrides.html#override/2)
1835 |
1836 | Define overrides for a specific component.
1837 |
1838 | [set(selector, value)](AshAuthentication.Phoenix.Overrides.html#set/2)
1839 |
1840 | Override a setting within a component.
1841 |
1842 | # [](AshAuthentication.Phoenix.Overrides.html#functions)Functions
1843 |
1844 | [](AshAuthentication.Phoenix.Overrides.html#override/2)
1845 |
1846 | # override(component, list)
1847 |
1848 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides.ex#L54)(macro)
1849 |
1850 | ```
1851 | @spec override(component :: module(), [{:do, Macro.t()}]) :: Macro.t()
1852 | ```
1853 |
1854 | Define overrides for a specific component.
1855 |
1856 | [](AshAuthentication.Phoenix.Overrides.html#set/2)
1857 |
1858 | # set(selector, value)
1859 |
1860 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides.ex#L65)(macro)
1861 |
1862 | ```
1863 | @spec set(atom(), any()) :: Macro.t()
1864 | ```
1865 |
1866 | Override a setting within a component.
1867 |
1868 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1869 |
1870 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1871 | [ash\_authentication\_phoenix](readme.html)
1872 |
1873 | v2.4.5
1874 |
1875 | - Pages
1876 | - Modules
1877 | - Mix Tasks
1878 |
1879 | <!--THE END-->
1880 |
1881 | <!--THE END-->
1882 |
1883 | <!--THE END-->
1884 |
1885 | Search documentation of ash\_authentication\_phoenix
1886 |
1887 | Settings
1888 |
1889 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/info.ex#L1 "View Source") AshAuthentication.Phoenix.Overrides.Info (ash\_authentication\_phoenix v2.4.5)
1890 |
1891 | Override introspection.
1892 |
1893 | # [](AshAuthentication.Phoenix.Overrides.Info.html#summary)Summary
1894 |
1895 | ## [Functions](AshAuthentication.Phoenix.Overrides.Info.html#functions)
1896 |
1897 | [all\_overridable\_modules()](AshAuthentication.Phoenix.Overrides.Info.html#all_overridable_modules/0)
1898 |
1899 | Returns a map of all known overridable modules and their overrides.
1900 |
1901 | # [](AshAuthentication.Phoenix.Overrides.Info.html#functions)Functions
1902 |
1903 | [](AshAuthentication.Phoenix.Overrides.Info.html#all_overridable_modules/0)
1904 |
1905 | # all\_overridable\_modules()
1906 |
1907 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/info.ex#L10)
1908 |
1909 | ```
1910 | @spec all_overridable_modules() :: %{
1911 | required(module()) => %{required(atom()) => binary()}
1912 | }
1913 | ```
1914 |
1915 | Returns a map of all known overridable modules and their overrides.
1916 |
1917 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1918 |
1919 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1920 | [ash\_authentication\_phoenix](readme.html)
1921 |
1922 | v2.4.5
1923 |
1924 | - Pages
1925 | - Modules
1926 | - Mix Tasks
1927 |
1928 | <!--THE END-->
1929 |
1930 | <!--THE END-->
1931 |
1932 | <!--THE END-->
1933 |
1934 | Search documentation of ash\_authentication\_phoenix
1935 |
1936 | Settings
1937 |
1938 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/overridable.ex#L1 "View Source") AshAuthentication.Phoenix.Overrides.Overridable behaviour (ash\_authentication\_phoenix v2.4.5)
1939 |
1940 | Auto generates documentation and helpers for components.
1941 |
1942 | # [](AshAuthentication.Phoenix.Overrides.Overridable.html#summary)Summary
1943 |
1944 | ## [Callbacks](AshAuthentication.Phoenix.Overrides.Overridable.html#callbacks)
1945 |
1946 | [\_\_overrides\_\_()](AshAuthentication.Phoenix.Overrides.Overridable.html#c:__overrides__/0)
1947 |
1948 | ## [Functions](AshAuthentication.Phoenix.Overrides.Overridable.html#functions)
1949 |
1950 | [override\_for(overrides, selector, default \\\\ nil)](AshAuthentication.Phoenix.Overrides.Overridable.html#override_for/3)
1951 |
1952 | Retrieve configuration for a potentially overriden value.
1953 |
1954 | # [](AshAuthentication.Phoenix.Overrides.Overridable.html#callbacks)Callbacks
1955 |
1956 | [](AshAuthentication.Phoenix.Overrides.Overridable.html#c:__overrides__/0)
1957 |
1958 | # \_\_overrides\_\_()
1959 |
1960 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/overridable.ex#L8)
1961 |
1962 | ```
1963 | @callback __overrides__() :: %{required(atom()) => binary()}
1964 | ```
1965 |
1966 | # [](AshAuthentication.Phoenix.Overrides.Overridable.html#functions)Functions
1967 |
1968 | [](AshAuthentication.Phoenix.Overrides.Overridable.html#override_for/3)
1969 |
1970 | # override\_for(overrides, selector, default \\\\ nil)
1971 |
1972 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/overrides/overridable.ex#L65)(macro)
1973 |
1974 | ```
1975 | @spec override_for([module()], atom(), any()) :: any()
1976 | ```
1977 |
1978 | Retrieve configuration for a potentially overriden value.
1979 |
1980 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
1981 |
1982 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
1983 | [ash\_authentication\_phoenix](readme.html)
1984 |
1985 | v2.4.5
1986 |
1987 | - Pages
1988 | - Modules
1989 | - Mix Tasks
1990 |
1991 | <!--THE END-->
1992 |
1993 | <!--THE END-->
1994 |
1995 | <!--THE END-->
1996 |
1997 | Search documentation of ash\_authentication\_phoenix
1998 |
1999 | Settings
2000 |
2001 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/plug.ex#L1 "View Source") AshAuthentication.Phoenix.Plug (ash\_authentication\_phoenix v2.4.5)
2002 |
2003 | Helper plugs mixed in to your router.
2004 |
2005 | When you `use AshAuthentication.Phoenix.Router` this module is included, so that you can use these plugs in your pipelines.
2006 |
2007 | # [](AshAuthentication.Phoenix.Plug.html#summary)Summary
2008 |
2009 | ## [Functions](AshAuthentication.Phoenix.Plug.html#functions)
2010 |
2011 | [load\_from\_bearer(conn, opts)](AshAuthentication.Phoenix.Plug.html#load_from_bearer/2)
2012 |
2013 | Attempt to retrieve actors from the `Authorization` header(s).
2014 |
2015 | [load\_from\_session(conn, opts)](AshAuthentication.Phoenix.Plug.html#load_from_session/2)
2016 |
2017 | Attempt to retrieve all actors from the connections' session.
2018 |
2019 | [revoke\_bearer\_tokens(conn, opts)](AshAuthentication.Phoenix.Plug.html#revoke_bearer_tokens/2)
2020 |
2021 | Revoke all token(s) in the `Authorization` header(s).
2022 |
2023 | [store\_in\_session(conn, actor)](AshAuthentication.Phoenix.Plug.html#store_in_session/2)
2024 |
2025 | Store the actor in the connections' session.
2026 |
2027 | # [](AshAuthentication.Phoenix.Plug.html#functions)Functions
2028 |
2029 | [](AshAuthentication.Phoenix.Plug.html#load_from_bearer/2)
2030 |
2031 | # load\_from\_bearer(conn, opts)
2032 |
2033 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/plug.ex#L33)
2034 |
2035 | ```
2036 | @spec load_from_bearer(
2037 | Plug.Conn.t(),
2038 | keyword()
2039 | ) :: Plug.Conn.t()
2040 | ```
2041 |
2042 | Attempt to retrieve actors from the `Authorization` header(s).
2043 |
2044 | A wrapper around [`AshAuthentication.Plug.Helpers.retrieve_from_bearer/2`](../ash_authentication/4.4.3/AshAuthentication.Plug.Helpers.html#retrieve_from_bearer/2) with the `otp_app` as extracted from the endpoint.
2045 |
2046 | [](AshAuthentication.Phoenix.Plug.html#load_from_session/2)
2047 |
2048 | # load\_from\_session(conn, opts)
2049 |
2050 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/plug.ex#L19)
2051 |
2052 | ```
2053 | @spec load_from_session(
2054 | Plug.Conn.t(),
2055 | keyword()
2056 | ) :: Plug.Conn.t()
2057 | ```
2058 |
2059 | Attempt to retrieve all actors from the connections' session.
2060 |
2061 | A wrapper around [`AshAuthentication.Plug.Helpers.retrieve_from_session/2`](../ash_authentication/4.4.3/AshAuthentication.Plug.Helpers.html#retrieve_from_session/2) with the `otp_app` as extracted from the endpoint.
2062 |
2063 | [](AshAuthentication.Phoenix.Plug.html#revoke_bearer_tokens/2)
2064 |
2065 | # revoke\_bearer\_tokens(conn, opts)
2066 |
2067 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/plug.ex#L47)
2068 |
2069 | ```
2070 | @spec revoke_bearer_tokens(Plug.Conn.t(), any()) :: Plug.Conn.t()
2071 | ```
2072 |
2073 | Revoke all token(s) in the `Authorization` header(s).
2074 |
2075 | A wrapper around [`AshAuthentication.Plug.Helpers.revoke_bearer_tokens/2`](../ash_authentication/4.4.3/AshAuthentication.Plug.Helpers.html#revoke_bearer_tokens/2) with the `otp_app` as extracted from the endpoint.
2076 |
2077 | [](AshAuthentication.Phoenix.Plug.html#store_in_session/2)
2078 |
2079 | # store\_in\_session(conn, actor)
2080 |
2081 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/plug.ex#L56)
2082 |
2083 | ```
2084 | @spec store_in_session(Plug.Conn.t(), Ash.Resource.record()) :: Plug.Conn.t()
2085 | ```
2086 |
2087 | Store the actor in the connections' session.
2088 |
2089 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2090 |
2091 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2092 | [ash\_authentication\_phoenix](readme.html)
2093 |
2094 | v2.4.5
2095 |
2096 | - Pages
2097 | - Modules
2098 | - Mix Tasks
2099 |
2100 | <!--THE END-->
2101 |
2102 | <!--THE END-->
2103 |
2104 | <!--THE END-->
2105 |
2106 | Search documentation of ash\_authentication\_phoenix
2107 |
2108 | Settings
2109 |
2110 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/reset_live.ex#L1 "View Source") AshAuthentication.Phoenix.ResetLive (ash\_authentication\_phoenix v2.4.5)
2111 |
2112 | A generic, white-label password reset page.
2113 |
2114 | This live-view can be rendered into your app using the [`AshAuthentication.Phoenix.Router.reset_route/1`](AshAuthentication.Phoenix.Router.html#reset_route/1) macro in your router (or by using [`Phoenix.LiveView.Controller.live_render/3`](../phoenix_live_view/1.0.2/Phoenix.LiveView.Controller.html#live_render/3) directly in your markup).
2115 |
2116 | This live-view looks for the `token` URL parameter, and if found passes it to [`AshAuthentication.Phoenix.Components.Reset`](AshAuthentication.Phoenix.Components.Reset.html).
2117 |
2118 | ## [](AshAuthentication.Phoenix.ResetLive.html#module-overrides)Overrides
2119 |
2120 | This component provides the following overrides:
2121 |
2122 | - `:root_class` - CSS class for the root `div` element.
2123 | - `:reset_id` - Element ID for the `Reset` LiveComponent.
2124 |
2125 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
2126 |
2127 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2128 |
2129 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2130 | [ash\_authentication\_phoenix](readme.html)
2131 |
2132 | v2.4.5
2133 |
2134 | - Pages
2135 | - Modules
2136 | - Mix Tasks
2137 |
2138 | <!--THE END-->
2139 |
2140 | <!--THE END-->
2141 |
2142 | <!--THE END-->
2143 |
2144 | Search documentation of ash\_authentication\_phoenix
2145 |
2146 | Settings
2147 |
2148 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L1 "View Source") AshAuthentication.Phoenix.Router (ash\_authentication\_phoenix v2.4.5)
2149 |
2150 | Phoenix route generation for AshAuthentication.
2151 |
2152 | Using this module imports the macros in this module and the plug functions from [`AshAuthentication.Phoenix.Plug`](AshAuthentication.Phoenix.Plug.html).
2153 |
2154 | ## [](AshAuthentication.Phoenix.Router.html#module-usage)Usage
2155 |
2156 | Adding authentication to your live-view router is very simple:
2157 |
2158 | ```
2159 | defmodule MyAppWeb.Router do
2160 | use MyAppWeb, :router
2161 | use AshAuthentication.Phoenix.Router
2162 |
2163 | pipeline :browser do
2164 | # ...
2165 | plug(:load_from_session)
2166 | end
2167 |
2168 | pipeline :api do
2169 | # ...
2170 | plug(:load_from_bearer)
2171 | end
2172 |
2173 | scope "/", MyAppWeb do
2174 | pipe_through :browser
2175 | sign_in_route auth_routes_prefix: "/auth"
2176 | sign_out_route AuthController
2177 | auth_routes_for MyApp.Accounts.User, to: AuthController
2178 | reset_route auth_routes_prefix: "/auth"
2179 | end
2180 | ```
2181 |
2182 | # [](AshAuthentication.Phoenix.Router.html#summary)Summary
2183 |
2184 | ## [Types](AshAuthentication.Phoenix.Router.html#types)
2185 |
2186 | [auth\_route\_options()](AshAuthentication.Phoenix.Router.html#t:auth_route_options/0)
2187 |
2188 | Options that can be passed to `auth_routes_for`.
2189 |
2190 | [path\_option()](AshAuthentication.Phoenix.Router.html#t:path_option/0)
2191 |
2192 | A sub-path if required. Defaults to `/auth`.
2193 |
2194 | [scope\_opts\_option()](AshAuthentication.Phoenix.Router.html#t:scope_opts_option/0)
2195 |
2196 | Any options which should be passed to the generated scope.
2197 |
2198 | [to\_option()](AshAuthentication.Phoenix.Router.html#t:to_option/0)
2199 |
2200 | The controller which will handle success and failure.
2201 |
2202 | ## [Functions](AshAuthentication.Phoenix.Router.html#functions)
2203 |
2204 | [auth\_routes(auth\_controller, resource\_or\_resources, opts \\\\ \[\])](AshAuthentication.Phoenix.Router.html#auth_routes/3)
2205 |
2206 | Generates the routes needed for the various strategies for a given AshAuthentication resource.
2207 |
2208 | [auth\_routes\_for(resource, opts)](AshAuthentication.Phoenix.Router.html#auth_routes_for/2)
2209 |
2210 | Generates the routes needed for the various strategies for a given AshAuthentication resource.
2211 |
2212 | [reset\_route(opts \\\\ \[\])](AshAuthentication.Phoenix.Router.html#reset_route/1)
2213 |
2214 | Generates a generic, white-label password reset page using LiveView and the components in `AshAuthentication.Phoenix.Components`. This is the page that allows a user to actually change his password, after requesting a reset token via the sign-in (`/reset`) route.
2215 |
2216 | [sign\_in\_route(opts \\\\ \[\])](AshAuthentication.Phoenix.Router.html#sign_in_route/1)
2217 |
2218 | Generates a generic, white-label sign-in page using LiveView and the components in `AshAuthentication.Phoenix.Components`.
2219 |
2220 | [sign\_out\_route(auth\_controller, path \\\\ "/sign-out", opts \\\\ \[\])](AshAuthentication.Phoenix.Router.html#sign_out_route/3)
2221 |
2222 | Generates a sign-out route which points to the `sign_out` action in your auth controller.
2223 |
2224 | # [](AshAuthentication.Phoenix.Router.html#types)Types
2225 |
2226 | [](AshAuthentication.Phoenix.Router.html#t:auth_route_options/0)
2227 |
2228 | # auth\_route\_options()
2229 |
2230 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L40)
2231 |
2232 | ```
2233 | @type auth_route_options() :: [path_option() | to_option() | scope_opts_option()]
2234 | ```
2235 |
2236 | Options that can be passed to `auth_routes_for`.
2237 |
2238 | [](AshAuthentication.Phoenix.Router.html#t:path_option/0)
2239 |
2240 | # path\_option()
2241 |
2242 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L43)
2243 |
2244 | ```
2245 | @type path_option() :: {:path, String.t()}
2246 | ```
2247 |
2248 | A sub-path if required. Defaults to `/auth`.
2249 |
2250 | [](AshAuthentication.Phoenix.Router.html#t:scope_opts_option/0)
2251 |
2252 | # scope\_opts\_option()
2253 |
2254 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L49)
2255 |
2256 | ```
2257 | @type scope_opts_option() :: {:scope_opts, keyword()}
2258 | ```
2259 |
2260 | Any options which should be passed to the generated scope.
2261 |
2262 | [](AshAuthentication.Phoenix.Router.html#t:to_option/0)
2263 |
2264 | # to\_option()
2265 |
2266 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L46)
2267 |
2268 | ```
2269 | @type to_option() :: {:to, AshAuthentication.Phoenix.Controller.t()}
2270 | ```
2271 |
2272 | The controller which will handle success and failure.
2273 |
2274 | # [](AshAuthentication.Phoenix.Router.html#functions)Functions
2275 |
2276 | [](AshAuthentication.Phoenix.Router.html#auth_routes/3)
2277 |
2278 | # auth\_routes(auth\_controller, resource\_or\_resources, opts \\\\ \[])
2279 |
2280 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L155)(macro)
2281 |
2282 | ```
2283 | @spec auth_routes(
2284 | auth_controller :: module(),
2285 | Ash.Resource.t() | [Ash.Resource.t()],
2286 | auth_route_options()
2287 | ) :: Macro.t()
2288 | ```
2289 |
2290 | Generates the routes needed for the various strategies for a given AshAuthentication resource.
2291 |
2292 | This matches *all* routes at the provided `path`, which defaults to `/auth`. This means that if you have any other routes that begin with `/auth`, you will need to make sure this appears after them.
2293 |
2294 | ## [](AshAuthentication.Phoenix.Router.html#auth_routes/3-upgrading-from-auth_routes_for-2)Upgrading from [`auth_routes_for/2`](AshAuthentication.Phoenix.Router.html#auth_routes_for/2)
2295 |
2296 | If you are using route helpers anywhere in your application, typically looks like `Routes.auth_path/3` or `Helpers.auth_path/3` you will need to update them to use verified routes. To see what routes are available to you, use [`mix ash_authentication.phoenix.routes`](Mix.Tasks.AshAuthentication.Phoenix.Routes.html).
2297 |
2298 | If you are using any of the components provided by `AshAuthenticationPhoenix`, you will need to supply them with the `auth_routes_prefix` assign, set to the `path` you provide here (set to `/auth` by default).
2299 |
2300 | You also will need to set `auth_routes_prefix` on the `reset_route`, i.e `reset_route(auth_routes_prefix: "/auth")`
2301 |
2302 | ## [](AshAuthentication.Phoenix.Router.html#auth_routes/3-options)Options
2303 |
2304 | - `path` - the path to mount auth routes at. Defaults to `/auth`. If changed, you will also want to change the `auth_routes_prefix` option in `sign_in_route` to match. routes.
2305 | - `not_found_plug` - a plug to call if no route is found. By default, it renders a simple JSON response with a 404 status code.
2306 | - `as` - the alias to use for the generated scope. Defaults to `:auth`.
2307 |
2308 | [](AshAuthentication.Phoenix.Router.html#auth_routes_for/2)
2309 |
2310 | # auth\_routes\_for(resource, opts)
2311 |
2312 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L88)(macro)
2313 |
2314 | ```
2315 | @spec auth_routes_for(Ash.Resource.t(), auth_route_options()) :: Macro.t()
2316 | ```
2317 |
2318 | Generates the routes needed for the various strategies for a given AshAuthentication resource.
2319 |
2320 | This is required if you wish to use authentication.
2321 |
2322 | ## [](AshAuthentication.Phoenix.Router.html#auth_routes_for/2-options)Options
2323 |
2324 | - `to` - a module which implements the [`AshAuthentication.Phoenix.Controller`](AshAuthentication.Phoenix.Controller.html) behaviour. This is required.
2325 | - `path` - a string (starting with "/") wherein to mount the generated routes.
2326 | - `scope_opts` - any options to pass to the generated scope.
2327 |
2328 | ## [](AshAuthentication.Phoenix.Router.html#auth_routes_for/2-example)Example
2329 |
2330 | ```
2331 | scope "/", DevWeb do
2332 | auth_routes_for(MyApp.Accounts.User,
2333 | to: AuthController,
2334 | path: "/authentication",
2335 | scope_opts: [host: "auth.example.com"]
2336 | )
2337 | end
2338 | ```
2339 |
2340 | [](AshAuthentication.Phoenix.Router.html#reset_route/1)
2341 |
2342 | # reset\_route(opts \\\\ \[])
2343 |
2344 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L381)(macro)
2345 |
2346 | ```
2347 | @spec reset_route(
2348 | opts :: [
2349 | {:path, String.t()}
2350 | | {:live_view, module()}
2351 | | {:as, atom()}
2352 | | {:overrides, [module()]}
2353 | | {:gettext_fn, {module(), atom()}}
2354 | | {:gettext_backend, {module(), String.t()}}
2355 | | {:on_mount, [module()]}
2356 | | {atom(), any()}
2357 | ]
2358 | ) :: Macro.t()
2359 | ```
2360 |
2361 | Generates a generic, white-label password reset page using LiveView and the components in `AshAuthentication.Phoenix.Components`. This is the page that allows a user to actually change his password, after requesting a reset token via the sign-in (`/reset`) route.
2362 |
2363 | Available options are:
2364 |
2365 | - `path` the path under which to mount the live-view. Defaults to `/password-reset`.
2366 | - `live_view` the name of the live view to render. Defaults to [`AshAuthentication.Phoenix.ResetLive`](AshAuthentication.Phoenix.ResetLive.html).
2367 | - `as` which is passed to the generated `live` route. Defaults to `:auth`.
2368 | - `overrides` specify any override modules for customisation. See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
2369 | - `gettext_fn` as a `{module :: module, function :: atom}` tuple pointing to a `(msgid :: String.t(), bindings :: keyword) :: String.t()` typed function that will be called to translate each output text of the live view.
2370 | - `gettext_backend` as a `{module :: module, domain :: String.t()}` tuple pointing to a Gettext backend module and specifying the Gettext domain. This is basically a convenience wrapper around `gettext_fn`.
2371 |
2372 | All other options are passed to the generated `scope`.
2373 |
2374 | [](AshAuthentication.Phoenix.Router.html#sign_in_route/1)
2375 |
2376 | # sign\_in\_route(opts \\\\ \[])
2377 |
2378 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L225)(macro)
2379 |
2380 | ```
2381 | @spec sign_in_route(
2382 | opts :: [
2383 | {:path, String.t()}
2384 | | {:live_view, module()}
2385 | | {:as, atom()}
2386 | | {:on_mount, [module()]}
2387 | | {:overrides, [module()]}
2388 | | {:gettext_fn, {module(), atom()}}
2389 | | {:gettext_backend, {module(), String.t()}}
2390 | | {atom(), any()}
2391 | ]
2392 | ) :: Macro.t()
2393 | ```
2394 |
2395 | Generates a generic, white-label sign-in page using LiveView and the components in `AshAuthentication.Phoenix.Components`.
2396 |
2397 | This is completely optional.
2398 |
2399 | Available options are:
2400 |
2401 | - `path` the path under which to mount the sign-in live-view. Defaults to `/sign-in` within the current router scope.
2402 | - `auth_routes_prefix` if set, this will be used instead of route helpers when determining routes. Allows disabling `helpers: true`. If a tuple {:unscoped, path} is provided, the path prefix will not inherit the current route scope.
2403 | - `register_path` - the path under which to mount the password strategy's registration live-view. If not set, and registration is supported, registration will use a dynamic toggle and will not be routeable to. If a tuple {:unscoped, path} is provided, the registration path will not inherit the current route scope.
2404 | - `reset_path` - the path under which to mount the password strategy's password reset live-view, for a user to request a reset token by email. If not set, and password reset is supported, password reset will use a dynamic toggle and will not be routeable to. If a tuple {:unscoped, path} is provided, the reset path will not inherit the current route scope.
2405 | - `live_view` the name of the live view to render. Defaults to [`AshAuthentication.Phoenix.SignInLive`](AshAuthentication.Phoenix.SignInLive.html).
2406 | - `auth_routes_prefix` the prefix to use for the auth routes. Defaults to `/auth`.
2407 | - `as` which is used to prefix the generated `live_session` and `live` route name. Defaults to `:auth`.
2408 | - `otp_app` the otp app or apps to find authentication resources in. Pulls from the socket by default.
2409 | - `overrides` specify any override modules for customisation. See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
2410 | - `gettext_fn` as a `{module :: module, function :: atom}` tuple pointing to a `(msgid :: String.t(), bindings :: keyword) :: String.t()` typed function that will be called to translate each output text of the live view.
2411 | - `gettext_backend` as a `{module :: module, domain :: String.t()}` tuple pointing to a Gettext backend module and specifying the Gettext domain. This is basically a convenience wrapper around `gettext_fn`.
2412 |
2413 | All other options are passed to the generated `scope`.
2414 |
2415 | [](AshAuthentication.Phoenix.Router.html#sign_out_route/3)
2416 |
2417 | # sign\_out\_route(auth\_controller, path \\\\ "/sign-out", opts \\\\ \[])
2418 |
2419 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/router.ex#L337)(macro)
2420 |
2421 | ```
2422 | @spec sign_out_route(AshAuthentication.Phoenix.Controller.t(), path :: String.t(), [
2423 | {:as, atom()} | {atom(), any()}
2424 | ]) :: Macro.t()
2425 | ```
2426 |
2427 | Generates a sign-out route which points to the `sign_out` action in your auth controller.
2428 |
2429 | This is optional, but you probably want it.
2430 |
2431 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2432 |
2433 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2434 | [ash\_authentication\_phoenix](readme.html)
2435 |
2436 | v2.4.5
2437 |
2438 | - Pages
2439 | - Modules
2440 | - Mix Tasks
2441 |
2442 | <!--THE END-->
2443 |
2444 | <!--THE END-->
2445 |
2446 | <!--THE END-->
2447 |
2448 | Search documentation of ash\_authentication\_phoenix
2449 |
2450 | Settings
2451 |
2452 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/sign_in_live.ex#L1 "View Source") AshAuthentication.Phoenix.SignInLive (ash\_authentication\_phoenix v2.4.5)
2453 |
2454 | A generic, white-label sign-in page.
2455 |
2456 | This live-view can be rendered into your app using the [`AshAuthentication.Phoenix.Router.sign_in_route/1`](AshAuthentication.Phoenix.Router.html#sign_in_route/1) macro in your router (or by using [`Phoenix.LiveView.Controller.live_render/3`](../phoenix_live_view/1.0.2/Phoenix.LiveView.Controller.html#live_render/3) directly in your markup).
2457 |
2458 | This live-view finds all Ash resources with an authentication configuration (via [`AshAuthentication.authenticated_resources/1`](../ash_authentication/4.4.3/AshAuthentication.html#authenticated_resources/1)) and renders the appropriate UI for their providers using [`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html).
2459 |
2460 | ## [](AshAuthentication.Phoenix.SignInLive.html#module-overrides)Overrides
2461 |
2462 | This component provides the following overrides:
2463 |
2464 | - `:root_class` - CSS class for the root `div` element.
2465 | - `:sign_in_id` - Element ID for the `SignIn` LiveComponent.
2466 |
2467 | See [`AshAuthentication.Phoenix.Overrides`](AshAuthentication.Phoenix.Overrides.html) for more information.
2468 |
2469 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2470 |
2471 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2472 | [ash\_authentication\_phoenix](readme.html)
2473 |
2474 | v2.4.5
2475 |
2476 | - Pages
2477 | - Modules
2478 | - Mix Tasks
2479 |
2480 | <!--THE END-->
2481 |
2482 | <!--THE END-->
2483 |
2484 | <!--THE END-->
2485 |
2486 | Search documentation of ash\_authentication\_phoenix
2487 |
2488 | Settings
2489 |
2490 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/test/support/gettext.ex#L1 "View Source") AshAuthentication.Phoenix.Test.Gettext (ash\_authentication\_phoenix v2.4.5)
2491 |
2492 | Gettext stub, referenced in AshAuthentication.Phoenix.Test.Router
2493 |
2494 | # [](AshAuthentication.Phoenix.Test.Gettext.html#summary)Summary
2495 |
2496 | ## [Functions](AshAuthentication.Phoenix.Test.Gettext.html#functions)
2497 |
2498 | [handle\_missing\_bindings(exception, incomplete)](AshAuthentication.Phoenix.Test.Gettext.html#handle_missing_bindings/2)
2499 |
2500 | Callback implementation for [`Gettext.Backend.handle_missing_bindings/2`](../gettext/0.26.2/Gettext.Backend.html#c:handle_missing_bindings/2).
2501 |
2502 | [handle\_missing\_plural\_translation(locale, domain, msgctxt, msgid, msgid\_plural, n, bindings)](AshAuthentication.Phoenix.Test.Gettext.html#handle_missing_plural_translation/7)
2503 |
2504 | Callback implementation for [`Gettext.Backend.handle_missing_plural_translation/7`](../gettext/0.26.2/Gettext.Backend.html#c:handle_missing_plural_translation/7).
2505 |
2506 | [translate\_test(msgid, bindings)](AshAuthentication.Phoenix.Test.Gettext.html#translate_test/2)
2507 |
2508 | # [](AshAuthentication.Phoenix.Test.Gettext.html#functions)Functions
2509 |
2510 | [](AshAuthentication.Phoenix.Test.Gettext.html#handle_missing_bindings/2)
2511 |
2512 | # handle\_missing\_bindings(exception, incomplete)
2513 |
2514 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/test/support/gettext.ex#L6)
2515 |
2516 | Callback implementation for [`Gettext.Backend.handle_missing_bindings/2`](../gettext/0.26.2/Gettext.Backend.html#c:handle_missing_bindings/2).
2517 |
2518 | [](AshAuthentication.Phoenix.Test.Gettext.html#handle_missing_plural_translation/7)
2519 |
2520 | # handle\_missing\_plural\_translation(locale, domain, msgctxt, msgid, msgid\_plural, n, bindings)
2521 |
2522 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/test/support/gettext.ex#L6)
2523 |
2524 | Callback implementation for [`Gettext.Backend.handle_missing_plural_translation/7`](../gettext/0.26.2/Gettext.Backend.html#c:handle_missing_plural_translation/7).
2525 |
2526 | [](AshAuthentication.Phoenix.Test.Gettext.html#translate_test/2)
2527 |
2528 | # translate\_test(msgid, bindings)
2529 |
2530 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/test/support/gettext.ex#L9)
2531 |
2532 | ```
2533 | @spec translate_test(
2534 | String.t(),
2535 | keyword()
2536 | ) :: String.t()
2537 | ```
2538 |
2539 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2540 |
2541 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2542 | [ash\_authentication\_phoenix](readme.html)
2543 |
2544 | v2.4.5
2545 |
2546 | - Pages
2547 | - Modules
2548 | - Mix Tasks
2549 |
2550 | <!--THE END-->
2551 |
2552 | <!--THE END-->
2553 |
2554 | <!--THE END-->
2555 |
2556 | Search documentation of ash\_authentication\_phoenix
2557 |
2558 | Settings
2559 |
2560 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/utils/flash.ex#L1 "View Source") AshAuthentication.Phoenix.Utils.Flash (ash\_authentication\_phoenix v2.4.5)
2561 |
2562 | Utility functions for sending and receiving flash messages.
2563 |
2564 | # [](AshAuthentication.Phoenix.Utils.Flash.html#summary)Summary
2565 |
2566 | ## [Functions](AshAuthentication.Phoenix.Utils.Flash.html#functions)
2567 |
2568 | [on\_mount(name, params, session, socket)](AshAuthentication.Phoenix.Utils.Flash.html#on_mount/4)
2569 |
2570 | Attach a hook to receive flash messages sent from components, for rendering in the top-level liveview.
2571 |
2572 | [put\_flash!(socket, type, message)](AshAuthentication.Phoenix.Utils.Flash.html#put_flash!/3)
2573 |
2574 | Send flash messages from components, to be rendered in their parent liveview.
2575 |
2576 | # [](AshAuthentication.Phoenix.Utils.Flash.html#functions)Functions
2577 |
2578 | [](AshAuthentication.Phoenix.Utils.Flash.html#on_mount/4)
2579 |
2580 | # on\_mount(name, params, session, socket)
2581 |
2582 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/utils/flash.ex#L12)
2583 |
2584 | Attach a hook to receive flash messages sent from components, for rendering in the top-level liveview.
2585 |
2586 | [](AshAuthentication.Phoenix.Utils.Flash.html#put_flash!/3)
2587 |
2588 | # put\_flash!(socket, type, message)
2589 |
2590 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/ash_authentication_phoenix/utils/flash.ex#L25)
2591 |
2592 | Send flash messages from components, to be rendered in their parent liveview.
2593 |
2594 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
2595 |
2596 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
2597 | [ash\_authentication\_phoenix](readme.html)
2598 |
2599 | v2.4.5
2600 |
2601 | - Pages
2602 | - Modules
2603 | - Mix Tasks
2604 |
2605 | <!--THE END-->
2606 |
2607 | <!--THE END-->
2608 |
2609 | <!--THE END-->
2610 |
2611 | Search documentation of ash\_authentication\_phoenix
2612 |
2613 | Settings
2614 |
2615 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/documentation/tutorials/get-started.md#L1 "View Source") Getting Started Ash Authentication Phoenix
2616 |
2617 | ### [](get-started.html#with-igniter)With Igniter
2618 |
2619 | This will also install `ash_authentication` if you haven't run that installer.
2620 |
2621 | ```
2622 | mix igniter.install ash_authentication_phoenix
2623 | ```
2624 |
2625 | If you'd like to see only the changes that `ash_authentication_phoenix` makes, you can run:
2626 |
2627 | ```
2628 | mix igniter.install ash_authentication
2629 | # and then run
2630 | mix igniter.install ash_authentication_phoenix
2631 | ```
2632 |
2633 | See the [AshAuthentication getting started guide](../ash_authentication/get-started.html) for information on how to add strategies and configure [`AshAuthentication`](../ash_authentication/4.4.3/AshAuthentication.html) if you have not already.
2634 |
2635 | ### [](get-started.html#manual)Manual
2636 |
2637 | #### Router Setup
2638 |
2639 | `ash_authentication_phoenix` includes several helper macros which can generate Phoenix routes for you. For that you need to add 6 lines in the router module or just replace the whole file with the following code:
2640 |
2641 | **lib/example\_web/router.ex**
2642 |
2643 | ```
2644 | defmodule ExampleWeb.Router do
2645 | use ExampleWeb, :router
2646 |
2647 | use AshAuthentication.Phoenix.Router # <-------- Add this line
2648 |
2649 | pipeline :browser do
2650 | plug :accepts, ["html"]
2651 | plug :fetch_session
2652 | plug :fetch_live_flash
2653 | plug :put_root_layout, {ExampleWeb.Layouts, :root}
2654 | plug :protect_from_forgery
2655 | plug :put_secure_browser_headers
2656 | plug :load_from_session # <-------- Add this line
2657 | end
2658 |
2659 | pipeline :api do
2660 | plug :accepts, ["json"]
2661 | plug :load_from_bearer # <--------- Add this line
2662 | end
2663 |
2664 | scope "/", ExampleWeb do
2665 | pipe_through :browser
2666 |
2667 | get "/", PageController, :home
2668 |
2669 | # add these lines -->
2670 |
2671 | # Standard controller-backed routes
2672 | auth_routes AuthController, Example.Accounts.User, path: "/auth"
2673 | sign_out_route AuthController
2674 |
2675 | # Prebuilt LiveViews for signing in, registration, resetting, etc.
2676 | # Leave out `register_path` and `reset_path` if you don't want to support
2677 | # user registration and/or password resets respectively.
2678 | sign_in_route(register_path: "/register", reset_path: "/reset", auth_routes_prefix: "/auth")
2679 | reset_route [auth_routes_prefix: "/auth"]
2680 |
2681 | # <-- add these lines
2682 | end
2683 |
2684 | ...
2685 | end
2686 | ```
2687 |
2688 | #### AuthController
2689 |
2690 | While running [`mix phx.routes`](../phoenix/1.7.18/Mix.Tasks.Phx.Routes.html) you probably saw the warning message that the `ExampleWeb.AuthController.init/1 is undefined`. Let's fix that by creating a new controller:
2691 |
2692 | **lib/example\_web/controllers/auth\_controller.ex**
2693 |
2694 | ```
2695 | defmodule ExampleWeb.AuthController do
2696 | use ExampleWeb, :controller
2697 | use AshAuthentication.Phoenix.Controller
2698 |
2699 | def success(conn, _activity, user, _token) do
2700 | return_to = get_session(conn, :return_to) || ~p"/"
2701 |
2702 | conn
2703 | |> delete_session(:return_to)
2704 | |> store_in_session(user)
2705 | # If your resource has a different name, update the assign name here (i.e :current_admin)
2706 | |> assign(:current_user, user)
2707 | |> redirect(to: return_to)
2708 | end
2709 |
2710 | def failure(conn, _activity, _reason) do
2711 | conn
2712 | |> put_flash(:error, "Incorrect email or password")
2713 | |> redirect(to: ~p"/sign-in")
2714 | end
2715 |
2716 | def sign_out(conn, _params) do
2717 | return_to = get_session(conn, :return_to) || ~p"/"
2718 |
2719 | conn
2720 | |> clear_session()
2721 | |> redirect(to: return_to)
2722 | end
2723 | end
2724 | ```
2725 |
2726 | ## [](get-started.html#generated-routes)Generated routes
2727 |
2728 | Given the above configuration you should see the following in your routes:
2729 |
2730 | ```
2731 | # mix phx.routes
2732 |
2733 | Generated example app
2734 | auth_path GET /sign-in AshAuthentication.Phoenix.SignInLive :sign_in
2735 | auth_path GET /sign-out ExampleWeb.AuthController :sign_out
2736 | auth_path * /auth/user/password/register ExampleWeb.AuthController {:user, :password, :register}
2737 | auth_path * /auth/user/password/sign_in ExampleWeb.AuthController {:user, :password, :sign_in}
2738 | page_path GET / ExampleWeb.PageController :home
2739 | ...
2740 | ```
2741 |
2742 | ### [](get-started.html#customizing-the-generated-routes)Customizing the generated routes
2743 |
2744 | If you're integrating AshAuthentication into an existing app, you probably already have existing HTML layouts you want to use, to wrap the provided sign in/forgot password/etc. forms.
2745 |
2746 | Liveviews provided by AshAuthentication.Phoenix will use the same root layout configured in your router's `:browser` pipeline, but it includes its own layout file primarily for rendering flash messages.
2747 |
2748 | If you would like to use your own layout file instead, you can specify this as an option to the route helpers, eg.
2749 |
2750 | ```
2751 | reset_route(layout: {MyAppWeb, :live}, auth_routes_prefix: "/auth")
2752 | ```
2753 |
2754 | ## [](get-started.html#tailwind)Tailwind
2755 |
2756 | If you plan on using our default [Tailwind](https://tailwindcss.com/)-based components without overriding them you will need to modify your `assets/tailwind.config.js` to include the `ash_authentication_phoenix` dependency:
2757 |
2758 | **assets/tailwind.config.js**
2759 |
2760 | ```
2761 | // See the Tailwind configuration guide for advanced usage
2762 | // https://tailwindcss.com/docs/configuration
2763 |
2764 | const plugin = require("tailwindcss/plugin");
2765 |
2766 | module.exports = {
2767 | content: [
2768 | "./js/**/*.js",
2769 | "../lib/*_web.ex",
2770 | "../lib/*_web/**/*.*ex",
2771 | "../deps/ash_authentication_phoenix/**/*.*ex", // <-- Add this line
2772 | ],
2773 | theme: {
2774 | extend: {
2775 | colors: {
2776 | brand: "#FD4F00",
2777 | },
2778 | },
2779 | },
2780 | plugins: [
2781 | require("@tailwindcss/forms"),
2782 | plugin(({ addVariant }) =>
2783 | addVariant("phx-no-feedback", [
2784 | ".phx-no-feedback&",
2785 | ".phx-no-feedback &",
2786 | ]),
2787 | ),
2788 | plugin(({ addVariant }) =>
2789 | addVariant("phx-click-loading", [
2790 | ".phx-click-loading&",
2791 | ".phx-click-loading &",
2792 | ]),
2793 | ),
2794 | plugin(({ addVariant }) =>
2795 | addVariant("phx-submit-loading", [
2796 | ".phx-submit-loading&",
2797 | ".phx-submit-loading &",
2798 | ]),
2799 | ),
2800 | plugin(({ addVariant }) =>
2801 | addVariant("phx-change-loading", [
2802 | ".phx-change-loading&",
2803 | ".phx-change-loading &",
2804 | ]),
2805 | ),
2806 | ],
2807 | };
2808 | ```
2809 |
2810 | ## [](get-started.html#example-home-html-heex)Example home.html.heex
2811 |
2812 | If you've just created your application, you can replace the default Phoenix `home.html.eex` with a minimal example which has a top navbar. On the right side it shows the `@current_user` and a sign out button. If you are not signed in you will see a sign in button.
2813 |
2814 | **lib/example\_web/controllers/page\_html/home.html.heex**
2815 |
2816 | ```
2817 | <nav class="bg-gray-800">
2818 | <div class="px-2 mx-auto max-w-7xl sm:px-6 lg:px-8">
2819 | <div class="relative flex items-center justify-between h-16">
2820 | <div
2821 | class="flex items-center justify-center flex-1 sm:items-stretch sm:justify-start"
2822 | >
2823 | <div class="block ml-6">
2824 | <div class="flex space-x-4">
2825 | <div class="px-3 py-2 text-xl font-medium text-white ">
2826 | Ash Demo
2827 | </div>
2828 | </div>
2829 | </div>
2830 | </div>
2831 | <div
2832 | class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0"
2833 | >
2834 | <%= if @current_user do %>
2835 | <span class="px-3 py-2 text-sm font-medium text-white rounded-md">
2836 | <%= @current_user.email %>
2837 | </span>
2838 | <a
2839 | href="/sign-out"
2840 | class="rounded-lg bg-zinc-100 px-2 py-1 text-[0.8125rem] font-semibold leading-6 text-zinc-900 hover:bg-zinc-200/80 active:text-zinc-900/70"
2841 | >
2842 | Sign out
2843 | </a>
2844 | <% else %>
2845 | <a
2846 | href="/sign-in"
2847 | class="rounded-lg bg-zinc-100 px-2 py-1 text-[0.8125rem] font-semibold leading-6 text-zinc-900 hover:bg-zinc-200/80 active:text-zinc-900/70"
2848 | >
2849 | Sign In
2850 | </a>
2851 | <% end %>
2852 | </div>
2853 | </div>
2854 | </div>
2855 | </nav>
2856 |
2857 | <div class="py-10">
2858 | <header>
2859 | <div class="px-4 mx-auto max-w-7xl sm:px-6 lg:px-8">
2860 | <h1 class="text-3xl font-bold leading-tight tracking-tight text-gray-900">
2861 | Demo
2862 | </h1>
2863 | </div>
2864 | </header>
2865 | <main>
2866 | <div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
2867 | <div class="px-4 py-8 sm:px-0">
2868 | <div
2869 | class="border-4 border-gray-200 border-dashed rounded-lg h-96"
2870 | ></div>
2871 | </div>
2872 | </div>
2873 | </main>
2874 | </div>
2875 | ```
2876 |
2877 | ### [](get-started.html#if-you-are-using-liveview)If you are using LiveView
2878 |
2879 | If you are using LiveView, jump over to the [Use AshAuthentication with LiveView](liveview.html) section and set up your LiveView routes for [`AshAuthentication`](../ash_authentication/4.4.3/AshAuthentication.html). Once that is done, you can proceed with the following steps.
2880 |
2881 | ### [](get-started.html#configure-strategies)Configure strategies
2882 |
2883 | By default, no strategies are included. See the [getting started guide](../ash_authentication/get-started.html) in [`AshAuthentication`](../ash_authentication/4.4.3/AshAuthentication.html) for more on setting up individual authentication strategies.
2884 |
2885 | ### [](get-started.html#start-phoenix)Start Phoenix
2886 |
2887 | You can now start Phoenix and visit [`localhost:4000`](http://localhost:4000) from your browser.
2888 |
2889 | ```
2890 | $ mix phx.server
2891 | ```
2892 |
2893 | ### [](get-started.html#sign-in)Sign In
2894 |
2895 | Visit [`localhost:4000/sign-in`](http://localhost:4000/sign-in) from your browser.
2896 |
2897 | The sign in page shows a link to register a new account.
2898 |
2899 | ### [](get-started.html#sign-out)Sign Out
2900 |
2901 | Visit [`localhost:4000/sign-out`](http://localhost:4000/sign-out) from your browser.
2902 |
2903 | ### [](get-started.html#debugging-the-authentication-flow)Debugging the Authentication flow
2904 |
2905 | The default authentication view shows a generic error message to users if their sign-in fails, like "Email or password was incorrect". This is for security purposes - you don't want potentially malicious people to know if an email address definitively exists in your system.
2906 |
2907 | However, if you're having issues setting up AshAuthentication, or trying to debug issues with your implementation, that error message isn't super useful to figure out what's going wrong.
2908 |
2909 | To that end, AshAuthentication comes with debug functionality that can be enabled in dev:
2910 |
2911 | **config/dev.exs**
2912 |
2913 | ```
2914 | config :ash_authentication, debug_authentication_failures?: true
2915 | ```
2916 |
2917 | #### Don't enable debugging outside `dev` environments!
2918 |
2919 | This could leak users' personally-identifiable information (PII) into your logs on failed sign-in attempts - a security issue!
2920 |
2921 | Once the config is added, you can restart your dev server and test what happens when you visit the sign-in page and submit invalid credentials. You should see log messages like -
2922 |
2923 | ```
2924 | [timestamp] [warning] Authentication failed: Query returned no users
2925 |
2926 | Details: %AshAuthentication.Errors.AuthenticationFailed{
2927 | field: nil,
2928 | strategy: %AshAuthentication.Strategy.Password{
2929 | confirmation_required?: true,
2930 | ...
2931 | ```
2932 |
2933 | ## [](get-started.html#reset-password)Reset Password
2934 |
2935 | In this section we add a reset password functionality. Which is triggered by adding `resettable` in the `User` resource. Please replace the `strategies` block in `lib/example/accounts/user.ex` with the following code:
2936 |
2937 | **lib/example/accounts/user.ex**
2938 |
2939 | ```
2940 | # [...]
2941 | strategies do
2942 | password :password do
2943 | identity_field :email
2944 |
2945 | resettable do
2946 | sender Example.Accounts.User.Senders.SendPasswordResetEmail
2947 | end
2948 | end
2949 | end
2950 | # [...]
2951 | ```
2952 |
2953 | To make this work we need to create a new module `Example.Accounts.User.Senders.SendPasswordResetEmail`:
2954 |
2955 | **lib/example/accounts/user/senders/send\_password\_reset\_email.ex**
2956 |
2957 | ```
2958 | defmodule Example.Accounts.User.Senders.SendPasswordResetEmail do
2959 | @moduledoc """
2960 | Sends a password reset email
2961 | """
2962 | use AshAuthentication.Sender
2963 | use ExampleWeb, :verified_routes
2964 |
2965 | @impl AshAuthentication.Sender
2966 | def send(user, token, _) do
2967 | Example.Accounts.Emails.deliver_reset_password_instructions(
2968 | user,
2969 | url(~p"/password-reset/#{token}")
2970 | )
2971 | end
2972 | end
2973 | ```
2974 |
2975 | We also need to create a new email template:
2976 |
2977 | **lib/example/accounts/emails.ex**
2978 |
2979 | ```
2980 | defmodule Example.Accounts.Emails do
2981 | @moduledoc """
2982 | Delivers emails.
2983 | """
2984 |
2985 | import Swoosh.Email
2986 |
2987 | def deliver_reset_password_instructions(user, url) do
2988 | if !url do
2989 | raise "Cannot deliver reset instructions without a url"
2990 | end
2991 |
2992 | deliver(user.email, "Reset Your Password", """
2993 | <html>
2994 | <p>
2995 | Hi #{user.email},
2996 | </p>
2997 |
2998 | <p>
2999 | <a href="#{url}">Click here</a> to reset your password.
3000 | </p>
3001 |
3002 | <p>
3003 | If you didn't request this change, please ignore this.
3004 | </p>
3005 | <html>
3006 | """)
3007 | end
3008 |
3009 | # For simplicity, this module simply logs messages to the terminal.
3010 | # You should replace it by a proper email or notification tool, such as:
3011 | #
3012 | # * Swoosh - https://hexdocs.pm/swoosh
3013 | # * Bamboo - https://hexdocs.pm/bamboo
3014 | #
3015 | defp deliver(to, subject, body) do
3016 | IO.puts("Sending email to #{to} with subject #{subject} and body #{body}")
3017 |
3018 | new()
3019 | |> from({"Zach", "[email protected]"}) # TODO: Replace with your email
3020 | |> to(to_string(to))
3021 | |> subject(subject)
3022 | |> put_provider_option(:track_links, "None")
3023 | |> html_body(body)
3024 | |> Example.Mailer.deliver!()
3025 | end
3026 | end
3027 | ```
3028 |
3029 | Your new reset password functionality is active. Visit [`localhost:4000/sign-in`](http://localhost:4000/sign-in) with your browser and click on the `Forgot your password?` link to trigger the reset password workflow.
3030 |
3031 | [← Previous Page README](readme.html)
3032 |
3033 | [Next Page → LiveView Routes](liveview.html)
3034 |
3035 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) ([current file](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5/show/documentation/tutorials/get-started.md)) Search HexDocs
3036 |
3037 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3038 | [ash\_authentication\_phoenix](readme.html)
3039 |
3040 | v2.4.5
3041 |
3042 | - Pages
3043 | - Modules
3044 | - Mix Tasks
3045 |
3046 | <!--THE END-->
3047 |
3048 | <!--THE END-->
3049 |
3050 | <!--THE END-->
3051 |
3052 | Search documentation of ash\_authentication\_phoenix
3053 |
3054 | Settings
3055 |
3056 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/documentation/tutorials/liveview.md#L1 "View Source") Setting up your routes for LiveView
3057 |
3058 | A built in live session wrapper is provided that will set the user assigns for you. To use it, wrap your live routes like so:
3059 |
3060 | ```
3061 | ash_authentication_live_session :session_name do
3062 | live "/route", ProjectLive.Index, :index
3063 | end
3064 | ```
3065 |
3066 | There are two problems with the above, however.
3067 |
3068 | 1. If there is no user present, it will not set `current_user: nil`.
3069 | 2. You may want a way to require that a user is present for some routes, and not for others.
3070 |
3071 | ## [](liveview.html#authentication-helper)Authentication helper
3072 |
3073 | To accomplish this, we use standard Phoenix [`on_mount` hooks](../phoenix_live_view/Phoenix.LiveView.html#on_mount/1-examples). Lets define a hook that gives us three potential behaviors, one for optionally having a user signed in, one for requiring a signed in user, and one for requiring that there is no signed in user.
3074 |
3075 | ```
3076 | # lib/my_app_web/live_user_auth.ex
3077 | defmodule MyAppWeb.LiveUserAuth do
3078 | @moduledoc """
3079 | Helpers for authenticating users in LiveViews.
3080 | """
3081 |
3082 | import Phoenix.Component
3083 | use MyAppWeb, :verified_routes
3084 |
3085 | def on_mount(:live_user_optional, _params, _session, socket) do
3086 | if socket.assigns[:current_user] do
3087 | {:cont, socket}
3088 | else
3089 | {:cont, assign(socket, :current_user, nil)}
3090 | end
3091 | end
3092 |
3093 | def on_mount(:live_user_required, _params, _session, socket) do
3094 | if socket.assigns[:current_user] do
3095 | {:cont, socket}
3096 | else
3097 | {:halt, Phoenix.LiveView.redirect(socket, to: ~p"/sign-in")}
3098 | end
3099 | end
3100 |
3101 | def on_mount(:live_no_user, _params, _session, socket) do
3102 | if socket.assigns[:current_user] do
3103 | {:halt, Phoenix.LiveView.redirect(socket, to: ~p"/")}
3104 | else
3105 | {:cont, assign(socket, :current_user, nil)}
3106 | end
3107 | end
3108 | end
3109 | ```
3110 |
3111 | And we can use this as follows:
3112 |
3113 | ```
3114 | # lib/my_app_web/router.ex
3115 | # ...
3116 | scope "/", MyAppWeb do
3117 | # ...
3118 | ash_authentication_live_session :authentication_required,
3119 | on_mount: {MyAppWeb.LiveUserAuth, :live_user_required} do
3120 | live "/protected_route", ProjectLive.Index, :index
3121 | end
3122 |
3123 | ash_authentication_live_session :authentication_optional,
3124 | on_mount: {MyAppWeb.LiveUserAuth, :live_user_optional} do
3125 | live "/", ProjectLive.Index, :index
3126 | end
3127 | end
3128 | # ...
3129 | ```
3130 |
3131 | You can also use this to prevent users from visiting the auto generated `sign_in` route:
3132 |
3133 | ```
3134 | sign_in_route(on_mount: [{MyAppWeb.LiveUserAuth, :live_no_user}])
3135 | ```
3136 |
3137 | [← Previous Page Get Started](get-started.html)
3138 |
3139 | [Next Page → UI Overrides](ui-overrides.html)
3140 |
3141 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) ([current file](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5/show/documentation/tutorials/liveview.md)) Search HexDocs
3142 |
3143 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3144 | [ash\_authentication\_phoenix](readme.html)
3145 |
3146 | v2.4.5
3147 |
3148 | - Pages
3149 | - Modules
3150 | - Mix Tasks
3151 |
3152 | <!--THE END-->
3153 |
3154 | <!--THE END-->
3155 |
3156 | <!--THE END-->
3157 |
3158 | Search documentation of ash\_authentication\_phoenix
3159 |
3160 | Settings
3161 |
3162 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/mix/tasks/ash_authentication_phoenix.install.ex#L4 "View Source") mix ash\_authentication\_phoenix.install (ash\_authentication\_phoenix v2.4.5)
3163 |
3164 | Installs AshAuthenticationPhoenix. Invoke with `mix igniter.install ash_authentication_phoenix`
3165 |
3166 | ## [](Mix.Tasks.AshAuthenticationPhoenix.Install.html#module-example)Example
3167 |
3168 | ```
3169 | mix igniter.install ash_authentication_phoenix
3170 | ```
3171 |
3172 | ## [](Mix.Tasks.AshAuthenticationPhoenix.Install.html#module-options)Options
3173 |
3174 | - `--accounts` or `-a` - The domain that contains your resources. Defaults to `YourApp.Accounts`.
3175 | - `--user` or `-u` - The resource that represents a user. Defaults to `<accounts>.User`.
3176 | - `--token` or `-t` - The resource that represents a token. Defaults to `<accounts>.Token`.
3177 |
3178 | # [](Mix.Tasks.AshAuthenticationPhoenix.Install.html#summary)Summary
3179 |
3180 | ## [Functions](Mix.Tasks.AshAuthenticationPhoenix.Install.html#functions)
3181 |
3182 | [igniter(igniter, argv)](Mix.Tasks.AshAuthenticationPhoenix.Install.html#igniter/2)
3183 |
3184 | Callback implementation for [`Igniter.Mix.Task.igniter/2`](../igniter/0.5.16/Igniter.Mix.Task.html#c:igniter/2).
3185 |
3186 | # [](Mix.Tasks.AshAuthenticationPhoenix.Install.html#functions)Functions
3187 |
3188 | [](Mix.Tasks.AshAuthenticationPhoenix.Install.html#igniter/2)
3189 |
3190 | # igniter(igniter, argv)
3191 |
3192 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/mix/tasks/ash_authentication_phoenix.install.ex#L48)
3193 |
3194 | Callback implementation for [`Igniter.Mix.Task.igniter/2`](../igniter/0.5.16/Igniter.Mix.Task.html#c:igniter/2).
3195 |
3196 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
3197 |
3198 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3199 | [ash\_authentication\_phoenix](readme.html)
3200 |
3201 | v2.4.5
3202 |
3203 | - Pages
3204 | - Modules
3205 | - Mix Tasks
3206 |
3207 | <!--THE END-->
3208 |
3209 | <!--THE END-->
3210 |
3211 | <!--THE END-->
3212 |
3213 | Search documentation of ash\_authentication\_phoenix
3214 |
3215 | Settings
3216 |
3217 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/mix/tasks/ash_authentication.phoenix.routes.ex#L1 "View Source") mix ash\_authentication.phoenix.routes (ash\_authentication\_phoenix v2.4.5)
3218 |
3219 | Prints all routes pertaining to AshAuthenticationPhoenix for the default or a given router.
3220 |
3221 | This task can be called directly, accepting the same options as [`mix phx.routes`](../phoenix/1.7.18/Mix.Tasks.Phx.Routes.html), except for `--info`.
3222 |
3223 | Alternatively, you can modify your aliases task to run them back to back it.
3224 |
3225 | ```
3226 | aliases: ["phx.routes": ["do", "phx.routes,", "ash_authentication.phx.routes"]]
3227 | ```
3228 |
3229 | # [](Mix.Tasks.AshAuthentication.Phoenix.Routes.html#summary)Summary
3230 |
3231 | ## [Functions](Mix.Tasks.AshAuthentication.Phoenix.Routes.html#functions)
3232 |
3233 | [get\_url\_info(url, arg)](Mix.Tasks.AshAuthentication.Phoenix.Routes.html#get_url_info/2)
3234 |
3235 | # [](Mix.Tasks.AshAuthentication.Phoenix.Routes.html#functions)Functions
3236 |
3237 | [](Mix.Tasks.AshAuthentication.Phoenix.Routes.html#get_url_info/2)
3238 |
3239 | # get\_url\_info(url, arg)
3240 |
3241 | [](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/lib/mix/tasks/ash_authentication.phoenix.routes.ex#L96)
3242 |
3243 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) Search HexDocs
3244 |
3245 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3246 | [ash\_authentication\_phoenix](readme.html)
3247 |
3248 | v2.4.5
3249 |
3250 | - Pages
3251 | - Modules
3252 | - Mix Tasks
3253 |
3254 | <!--THE END-->
3255 |
3256 | <!--THE END-->
3257 |
3258 | <!--THE END-->
3259 |
3260 | Search documentation of ash\_authentication\_phoenix
3261 |
3262 | Settings
3263 |
3264 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/README.md#L1 "View Source") README
3265 |
3266 |  
3267 |
3268 |  [](https://opensource.org/licenses/MIT) [](https://hex.pm/packages/ash_authentication_phoenix) [](../ash_authentication_phoenix.html)
3269 |
3270 | # Ash Authentication Phoenix
3271 |
3272 | Welcome! Here you will find everything you need to know to get started with Ash Authentication and Phoenix. This documentation is best viewed on [hexdocs](../ash_authentication_phoenix.html)
3273 |
3274 | ## [](readme.html#about-the-documentation)About the Documentation
3275 |
3276 | [**Tutorials**](readme.html#tutorials) walk you through a series of steps to accomplish a goal. These are **learning-oriented**, and are a great place for beginners to start.
3277 |
3278 | * * *
3279 |
3280 | [**Topics**](readme.html#topics) provide a high level overview of a specific concept or feature. These are **understanding-oriented**, and are perfect for discovering design patterns, features, and tools related to a given topic.
3281 |
3282 | * * *
3283 |
3284 | [**How-to**](readme.html#how-to) guides are **goal-oriented** recipes for accomplishing specific tasks. These are also good to browse to get an idea of how Ash Authentication works and what is possible with it.
3285 |
3286 | * * *
3287 |
3288 | [**Reference**](readme.html#reference) documentation is produced automatically from our source code. It comes in the form of module documentation and DSL documentation. This documentation is **information-oriented**. Use the sidebar and the search bar to find relevant reference information.
3289 |
3290 | ## [](readme.html#tutorials)Tutorials
3291 |
3292 | - [Get Started](get-started.html)
3293 | - [Using with LiveView](liveview.html)
3294 | - [Overriding UI](ui-overrides.html)
3295 |
3296 | ## [](readme.html#related-packages)Related packages
3297 |
3298 | - [Ash Framework](../ash.html)
3299 | - [Ash Authentication](../ash_authentication.html)
3300 |
3301 | * * *
3302 |
3303 | [](https://alembic.com.au)
3304 |
3305 | Proudly written and maintained by the team at [Alembic](https://alembic.com.au) for the Ash community.
3306 |
3307 | [← Previous Page API Reference](api-reference.html)
3308 |
3309 | [Next Page → Get Started](get-started.html)
3310 |
3311 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) ([current file](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5/show/README.md)) Search HexDocs
3312 |
3313 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3314 | [ash\_authentication\_phoenix](readme.html)
3315 |
3316 | v2.4.5
3317 |
3318 | - Pages
3319 | - Modules
3320 | - Mix Tasks
3321 |
3322 | <!--THE END-->
3323 |
3324 | <!--THE END-->
3325 |
3326 | <!--THE END-->
3327 |
3328 | Search documentation of ash\_authentication\_phoenix
3329 |
3330 | Settings
3331 |
3332 | # [View Source](https://github.com/team-alembic/ash_authentication_phoenix/blob/main/documentation/tutorials/ui-overrides.md#L1 "View Source") Overriding Ash Authentication Phoenix's default UI
3333 |
3334 | Ash Authentication Phoenix provides a default UI implementation to get you started, however we wanted there to be a middle road between "you gets what you gets" and "¯\\*(ツ)*/¯ make your own". Thus AAP's system of UI overrides were born.
3335 |
3336 | Each of our LiveView components has a number of hooks where you can override either the CSS styles, text or images.
3337 |
3338 | In addition you have the option to provide a `gettext/2` compatible function through which all output text will be run.
3339 |
3340 | ## [](ui-overrides.html#defining-overrides)Defining Overrides
3341 |
3342 | You override these components by defining an "overrides module", which you will then provide in your router when setting up your routes.
3343 |
3344 | For example, if we wanted to change the default banner used on the sign-in page:
3345 |
3346 | ```
3347 | defmodule MyAppWeb.AuthOverrides do
3348 | use AshAuthentication.Phoenix.Overrides
3349 |
3350 | # Override a property per component
3351 | override AshAuthentication.Phoenix.Components.Banner do
3352 | # include any number of properties you want to override
3353 | set :image_url, "/images/rickroll.gif"
3354 | end
3355 | end
3356 | ```
3357 |
3358 | You only need to define the overrides you want to change. Unspecified overrides will use their default value.
3359 |
3360 | ## [](ui-overrides.html#internationalisation)Internationalisation
3361 |
3362 | Plug in your Gettext backend and have all display text translated automagically, see next section for an example.
3363 |
3364 | The package includes Gettext templates for the untranslated messages and a growing number of translations. You might want to
3365 |
3366 | ```
3367 | cp -rv deps/ash_authentication_phoenix/i18n/gettext/* priv/gettext
3368 | ```
3369 |
3370 | For other i18n libraries you have the option to provide a gettext-like handler function, see [`AshAuthentication.Phoenix.Router.sign_in_route/1`](AshAuthentication.Phoenix.Router.html#sign_in_route/1) for details.
3371 |
3372 | ## [](ui-overrides.html#telling-ashauthentication-about-your-overrides)Telling AshAuthentication about your overrides
3373 |
3374 | To do this, you modify your `sign_in_route` calls to contain the `overrides` option. Be sure to put the [`AshAuthentication.Phoenix.Overrides.Default`](AshAuthentication.Phoenix.Overrides.Default.html) override last, as it contains the default values for all components!
3375 |
3376 | The same way you may add a `gettext_backend` option to specify your Gettext backend and domain.
3377 |
3378 | ```
3379 | defmodule MyAppWeb.Router do
3380 | use MyAppWeb, :router
3381 | use AshAuthentication.Phoenix.Router
3382 |
3383 | # ...
3384 |
3385 | scope "/", MyAppWeb do
3386 | sign_in_route overrides: [MyAppWeb.AuthOverrides, AshAuthentication.Phoenix.Overrides.Default],
3387 | gettext_backend: {MyAppWeb.Gettext, "auth"}
3388 | end
3389 | end
3390 | ```
3391 |
3392 | ## [](ui-overrides.html#reference)Reference
3393 |
3394 | The below documentation is autogenerated from the components that support overrides. All available overrides are listed here. If you are looking to override something not in this list, please open an issue, or even better a PR!
3395 |
3396 | Looking at the source of the components can be enlightening to see exactly how an override is used. If you click on the name of component you are interested in, and then look in the top right (if you are on hexdocs), you will see a `</>` button that will take you to the source for that component. In that code, look for calls to `override_for/3` to see specifically how each override is used.
3397 |
3398 | ## [](ui-overrides.html#sign-in)Sign In
3399 |
3400 | ### [](ui-overrides.html#ashauthentication-phoenix-signinlive)[`AshAuthentication.Phoenix.SignInLive`](AshAuthentication.Phoenix.SignInLive.html)
3401 |
3402 | A generic, white-label sign-in page.
3403 |
3404 | - `:root_class` - CSS class for the root `div` element.
3405 | - `:sign_in_id` - Element ID for the `SignIn` LiveComponent.
3406 |
3407 | ### [](ui-overrides.html#ashauthentication-phoenix-components-signin)[`AshAuthentication.Phoenix.Components.SignIn`](AshAuthentication.Phoenix.Components.SignIn.html)
3408 |
3409 | Renders sign in mark-up for an authenticated resource.
3410 |
3411 | - `:authentication_error_container_class` - CSS class for the container for the text of the authentication error.
3412 | - `:authentication_error_text_class` - CSS class for the authentication error text.
3413 | - `:root_class` - CSS class for the root `div` element.
3414 | - `:show_banner` - Whether or not to show the banner.
3415 | - `:strategy_class` - CSS class for a `div` surrounding each strategy component.
3416 |
3417 | ## [](ui-overrides.html#password-sign-in)Password Sign-in
3418 |
3419 | ### [](ui-overrides.html#ashauthentication-phoenix-components-password)[`AshAuthentication.Phoenix.Components.Password`](AshAuthentication.Phoenix.Components.Password.html)
3420 |
3421 | Generates sign in, registration and reset forms for a resource.
3422 |
3423 | - `:hide_class` - CSS class to apply to hide an element.
3424 | - `:interstitial_class` - CSS class for the `div` element between the form and the button.
3425 | - `:register_toggle_text` - Toggle text to display when the register form is not showing (or `nil` to disable).
3426 | - `:reset_toggle_text` - Toggle text to display when the reset form is not showing (or `nil` to disable).
3427 | - `:root_class` - CSS class for the root `div` element.
3428 | - `:show_first` - The form to show on first load. Either `:sign_in` or `:register`. Only relevant if paths aren't set for them in the router.
3429 | - `:sign_in_toggle_text` - Toggle text to display when the sign in form is not showing (or `nil` to disable).
3430 | - `:slot_class` - CSS class for the `div` surrounding the slot.
3431 | - `:toggler_class` - CSS class for the toggler `a` element.
3432 |
3433 | ### [](ui-overrides.html#ashauthentication-phoenix-components-password-registerform)[`AshAuthentication.Phoenix.Components.Password.RegisterForm`](AshAuthentication.Phoenix.Components.Password.RegisterForm.html)
3434 |
3435 | Generates a default registration form.
3436 |
3437 | - `:button_text` - Text for the submit button.
3438 | - `:disable_button_text` - Text for the submit button when the request is happening.
3439 | - `:form_class` - CSS class for the `form` element.
3440 | - `:label_class` - CSS class for the `h2` element.
3441 | - `:root_class` - CSS class for the root `div` element.
3442 | - `:slot_class` - CSS class for the `div` surrounding the slot.
3443 |
3444 | ### [](ui-overrides.html#ashauthentication-phoenix-components-password-signinform)[`AshAuthentication.Phoenix.Components.Password.SignInForm`](AshAuthentication.Phoenix.Components.Password.SignInForm.html)
3445 |
3446 | Generates a default sign in form.
3447 |
3448 | - `:button_text` - Text for the submit button.
3449 | - `:disable_button_text` - Text for the submit button when the request is happening.
3450 | - `:form_class` - CSS class for the `form` element.
3451 | - `:label_class` - CSS class for the `h2` element.
3452 | - `:root_class` - CSS class for the root `div` element.
3453 | - `:slot_class` - CSS class for the `div` surrounding the slot.
3454 |
3455 | ## [](ui-overrides.html#password-reset)Password Reset
3456 |
3457 | ### [](ui-overrides.html#ashauthentication-phoenix-resetlive)[`AshAuthentication.Phoenix.ResetLive`](AshAuthentication.Phoenix.ResetLive.html)
3458 |
3459 | A generic, white-label password reset page.
3460 |
3461 | - `:reset_id` - Element ID for the `Reset` LiveComponent.
3462 | - `:root_class` - CSS class for the root `div` element.
3463 |
3464 | ### [](ui-overrides.html#ashauthentication-phoenix-components-reset)[`AshAuthentication.Phoenix.Components.Reset`](AshAuthentication.Phoenix.Components.Reset.html)
3465 |
3466 | Renders a password-reset form.
3467 |
3468 | - `:root_class` - CSS class for the root `div` element.
3469 | - `:show_banner` - Whether or not to show the banner.
3470 | - `:strategy_class` - CSS class for a `div` surrounding each strategy component.
3471 |
3472 | ### [](ui-overrides.html#ashauthentication-phoenix-components-reset-form)[`AshAuthentication.Phoenix.Components.Reset.Form`](AshAuthentication.Phoenix.Components.Reset.Form.html)
3473 |
3474 | Generates a default password reset form.
3475 |
3476 | - `:disable_button_text` - Text for the submit button when the request is happening.
3477 | - `:form_class` - CSS class for the `form` element.
3478 | - `:label_class` - CSS class for the `h2` element.
3479 | - `:root_class` - CSS class for the root `div` element.
3480 | - `:spacer_class` - CSS classes for space between the password input and submit elements.
3481 |
3482 | ### [](ui-overrides.html#ashauthentication-phoenix-components-password-resetform)[`AshAuthentication.Phoenix.Components.Password.ResetForm`](AshAuthentication.Phoenix.Components.Password.ResetForm.html)
3483 |
3484 | Generates a default password reset form.
3485 |
3486 | - `:button_text` - Tex for the submit button.
3487 | - `:disable_button_text` - Text for the submit button when the request is happening.
3488 | - `:form_class` - CSS class for the `form` element.
3489 | - `:label_class` - CSS class for the `h2` element.
3490 | - `:reset_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.
3491 | - `:root_class` - CSS class for the root `div` element.
3492 | - `:slot_class` - CSS class for the `div` surrounding the slot.
3493 |
3494 | ## [](ui-overrides.html#password)Password
3495 |
3496 | ### [](ui-overrides.html#ashauthentication-phoenix-components-password-input)[`AshAuthentication.Phoenix.Components.Password.Input`](AshAuthentication.Phoenix.Components.Password.Input.html)
3497 |
3498 | Function components for dealing with form input during password authentication.
3499 |
3500 | - `:error_li` - CSS class for the `li` elements on error lists.
3501 | - `:error_ul` - CSS class for the `ul` element on error lists.
3502 | - `:field_class` - CSS class for `div` elements surrounding the fields.
3503 | - `:identity_input_label` - Label for identity field.
3504 | - `:identity_input_placeholder` - Placeholder for identity field.
3505 | - `:input_class` - CSS class for text/password `input` elements.
3506 | - `:input_class_with_error` - CSS class for text/password `input` elements when there is a validation error.
3507 | - `:input_debounce` - Number of milliseconds to debounce input by (or `nil` to disable).
3508 | - `:label_class` - CSS class for `label` elements.
3509 | - `:password_confirmation_input_label` - Label for password confirmation field.
3510 | - `:password_input_label` - Label for password field.
3511 | - `:submit_class` - CSS class for the form submit `input` element.
3512 |
3513 | ## [](ui-overrides.html#magic-link)Magic Link
3514 |
3515 | ### [](ui-overrides.html#ashauthentication-phoenix-components-magiclink)[`AshAuthentication.Phoenix.Components.MagicLink`](AshAuthentication.Phoenix.Components.MagicLink.html)
3516 |
3517 | Generates a sign-in for for a resource using the "Magic link" strategy.
3518 |
3519 | - `:disable_button_text` - Text for the submit button when the request is happening.
3520 | - `:form_class` - CSS class for the `form` element.
3521 | - `:label_class` - CSS class for the `h2` element.
3522 | - `:request_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.
3523 | - `:root_class` - CSS class for the root `div` element.
3524 |
3525 | ## [](ui-overrides.html#oauth2)OAuth2
3526 |
3527 | ### [](ui-overrides.html#ashauthentication-phoenix-components-apple)[`AshAuthentication.Phoenix.Components.Apple`](AshAuthentication.Phoenix.Components.Apple.html)
3528 |
3529 | Generates a sign-in button for Apple.
3530 |
3531 | - `:icon_class` - CSS classes for the icon SVG.
3532 | - `:link_class` - CSS classes for the `a` element.
3533 | - `:root_class` - CSS classes for the root `div` element.
3534 |
3535 | ### [](ui-overrides.html#ashauthentication-phoenix-components-oauth2)[`AshAuthentication.Phoenix.Components.OAuth2`](AshAuthentication.Phoenix.Components.OAuth2.html)
3536 |
3537 | Generates a sign-in button for OAuth2.
3538 |
3539 | - `:icon_class` - CSS classes for the icon SVG.
3540 | - `:link_class` - CSS classes for the `a` element.
3541 | - `:root_class` - CSS classes for the root `div` element.
3542 |
3543 | ## [](ui-overrides.html#miscellaneous)Miscellaneous
3544 |
3545 | ### [](ui-overrides.html#ashauthentication-phoenix-components-horizontalrule)[`AshAuthentication.Phoenix.Components.HorizontalRule`](AshAuthentication.Phoenix.Components.HorizontalRule.html)
3546 |
3547 | A horizontal rule with text.
3548 |
3549 | - `:hr_inner_class` - CSS class for the inner `div` element of the horizontal rule.
3550 | - `:hr_outer_class` - CSS class for the outer `div` element of the horizontal rule.
3551 | - `:root_class` - CSS class for the root `div` element.
3552 | - `:text` - Text to display in front of the horizontal rule.
3553 | - `:text_inner_class` - CSS class for the inner `div` element of the text area.
3554 | - `:text_outer_class` - CSS class for the outer `div` element of the text area.
3555 |
3556 | ### [](ui-overrides.html#ashauthentication-phoenix-components-banner)[`AshAuthentication.Phoenix.Components.Banner`](AshAuthentication.Phoenix.Components.Banner.html)
3557 |
3558 | Renders a very simple banner at the top of the sign-in component.
3559 |
3560 | - `:dark_image_class` - Css class for the `img` tag in dark mode.
3561 | - `:dark_image_url` - A URL for the `img` `src` attribute in dark mode. Set to `nil` to disable.
3562 | - `:href_class` - CSS class for the `a` tag.
3563 | - `:href_url` - A URL for the banner image to link to. Set to `nil` to disable.
3564 | - `:image_class` - CSS class for the `img` tag.
3565 | - `:image_url` - A URL for the `img` `src` attribute. Set to `nil` to disable.
3566 | - `:root_class` - CSS class for the root `div` element.
3567 | - `:text` - Banner text. Set to `nil` to disable.
3568 | - `:text_class` - CSS class for the text `div`.
3569 |
3570 | [← Previous Page LiveView Routes](liveview.html)
3571 |
3572 | [Hex Package](https://hex.pm/packages/ash_authentication_phoenix/2.4.5) [Hex Preview](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5) ([current file](https://preview.hex.pm/preview/ash_authentication_phoenix/2.4.5/show/documentation/tutorials/ui-overrides.md)) Search HexDocs
3573 |
3574 | Built using [ExDoc](https://github.com/elixir-lang/ex_doc "ExDoc") (v0.34.2) for the [Elixir programming language](https://elixir-lang.org "Elixir")
3575 |
```