rodauth_phlex 0.1.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +90 -0
- data/Rakefile +10 -0
- data/lib/rodauth_phlex/component.rb +15 -0
- data/lib/rodauth_phlex/components/add_recovery_codes.rb +21 -0
- data/lib/rodauth_phlex/components/button.rb +33 -0
- data/lib/rodauth_phlex/components/change_login.rb +22 -0
- data/lib/rodauth_phlex/components/email_auth_request_form.rb +20 -0
- data/lib/rodauth_phlex/components/formatted_field_error.rb +23 -0
- data/lib/rodauth_phlex/components/global_logout_field.rb +20 -0
- data/lib/rodauth_phlex/components/input_field.rb +74 -0
- data/lib/rodauth_phlex/components/login_confirm_field.rb +18 -0
- data/lib/rodauth_phlex/components/login_display.rb +19 -0
- data/lib/rodauth_phlex/components/login_field.rb +18 -0
- data/lib/rodauth_phlex/components/login_form.rb +25 -0
- data/lib/rodauth_phlex/components/login_form_footer.rb +20 -0
- data/lib/rodauth_phlex/components/login_hidden_field.rb +16 -0
- data/lib/rodauth_phlex/components/otp_auth_code_field.rb +22 -0
- data/lib/rodauth_phlex/components/password_confirm_field.rb +18 -0
- data/lib/rodauth_phlex/components/password_field.rb +18 -0
- data/lib/rodauth_phlex/components/recovery_codes.rb +24 -0
- data/lib/rodauth_phlex/components/sms_code_field.rb +22 -0
- data/lib/rodauth_phlex/components/webauthn_autofill.rb +26 -0
- data/lib/rodauth_phlex/components.rb +27 -0
- data/lib/rodauth_phlex/email.rb +23 -0
- data/lib/rodauth_phlex/emails/email_auth_email.rb +21 -0
- data/lib/rodauth_phlex/emails/otp_disabled_email.rb +18 -0
- data/lib/rodauth_phlex/emails/otp_locked_out_email.rb +25 -0
- data/lib/rodauth_phlex/emails/otp_setup_email.rb +18 -0
- data/lib/rodauth_phlex/emails/otp_unlock_failed_email.rb +24 -0
- data/lib/rodauth_phlex/emails/otp_unlocked_email.rb +18 -0
- data/lib/rodauth_phlex/emails/password_changed_email.rb +18 -0
- data/lib/rodauth_phlex/emails/reset_password_email.rb +21 -0
- data/lib/rodauth_phlex/emails/reset_password_notify_email.rb +21 -0
- data/lib/rodauth_phlex/emails/unlock_account_email.rb +21 -0
- data/lib/rodauth_phlex/emails/verify_account_email.rb +20 -0
- data/lib/rodauth_phlex/emails/verify_login_change_email.rb +25 -0
- data/lib/rodauth_phlex/emails/webauthn_authenticator_added_email.rb +19 -0
- data/lib/rodauth_phlex/emails/webauthn_authenticator_removed_email.rb +19 -0
- data/lib/rodauth_phlex/emails.rb +22 -0
- data/lib/rodauth_phlex/feature.rb +71 -0
- data/lib/rodauth_phlex/version.rb +5 -0
- data/lib/rodauth_phlex/view.rb +17 -0
- data/lib/rodauth_phlex/views/change_password.rb +25 -0
- data/lib/rodauth_phlex/views/close_account.rb +20 -0
- data/lib/rodauth_phlex/views/confirm_password.rb +20 -0
- data/lib/rodauth_phlex/views/create_account.rb +23 -0
- data/lib/rodauth_phlex/views/email_auth.rb +19 -0
- data/lib/rodauth_phlex/views/login.rb +17 -0
- data/lib/rodauth_phlex/views/logout.rb +19 -0
- data/lib/rodauth_phlex/views/multi_phase_login.rb +17 -0
- data/lib/rodauth_phlex/views/otp_auth.rb +21 -0
- data/lib/rodauth_phlex/views/otp_disable.rb +20 -0
- data/lib/rodauth_phlex/views/otp_setup.rb +39 -0
- data/lib/rodauth_phlex/views/otp_unlock.rb +24 -0
- data/lib/rodauth_phlex/views/otp_unlock_not_available.rb +23 -0
- data/lib/rodauth_phlex/views/recovery_auth.rb +23 -0
- data/lib/rodauth_phlex/views/remember.rb +33 -0
- data/lib/rodauth_phlex/views/reset_password.rb +21 -0
- data/lib/rodauth_phlex/views/reset_password_request.rb +25 -0
- data/lib/rodauth_phlex/views/sms_auth.rb +20 -0
- data/lib/rodauth_phlex/views/sms_confirm.rb +20 -0
- data/lib/rodauth_phlex/views/sms_disable.rb +20 -0
- data/lib/rodauth_phlex/views/sms_request.rb +19 -0
- data/lib/rodauth_phlex/views/sms_setup.rb +30 -0
- data/lib/rodauth_phlex/views/two_factor_auth.rb +19 -0
- data/lib/rodauth_phlex/views/two_factor_disable.rb +20 -0
- data/lib/rodauth_phlex/views/two_factor_manage.rb +28 -0
- data/lib/rodauth_phlex/views/unlock_account.rb +21 -0
- data/lib/rodauth_phlex/views/unlock_account_request.rb +21 -0
- data/lib/rodauth_phlex/views/verify_account.rb +21 -0
- data/lib/rodauth_phlex/views/verify_account_resend.rb +25 -0
- data/lib/rodauth_phlex/views/verify_login_change.rb +19 -0
- data/lib/rodauth_phlex/views/webauthn_auth.rb +27 -0
- data/lib/rodauth_phlex/views/webauthn_remove.rb +33 -0
- data/lib/rodauth_phlex/views/webauthn_setup.rb +28 -0
- data/lib/rodauth_phlex/views.rb +39 -0
- data/lib/rodauth_phlex.rb +13 -0
- metadata +162 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 68754c20c5164cedeaa8b95eed34f7afbd1e339e133801588f795a322fa47cbc
|
|
4
|
+
data.tar.gz: 4fd2cd9303eb3e92e1c7ebdc8a861c9ccca5b12c4ca883778d02728464622c0c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6b7242dc3a0592b8280c1987917b3069ab7d52abad28aa4a96b92f2c5be35b5abcf29764e6a4c50b0f4992df04edd793c32c7c22ed3408612e02f5457e41e3ca
|
|
7
|
+
data.tar.gz: e0677d40966d66ebfd4162b1d13a5cb583e41c00f6e8e0e823fb9d829c8dfbeb56d8916489696193552e4dc7a2a67ca3f9d405113e43108a9ac8134b9c864b14
|
data/.rspec
ADDED
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Robert Schulze
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# RodauthPhlex (EXPERIMENTAL)
|
|
2
|
+
|
|
3
|
+
Re-implementation of Rodauth templates in Phlex.
|
|
4
|
+
|
|
5
|
+
This allows you to use Rodauth with Phlex Vies and Components instead of the built-in templates which require `tilt`.
|
|
6
|
+
The motivation is to not have to depend on `tilt` and to be able to make customizations to the Rodauth templates easier.
|
|
7
|
+
|
|
8
|
+
Implements via the [`roda-phlex`](https://github.com/fnordfish/roda-phlex) gem.
|
|
9
|
+
|
|
10
|
+
**This gem should be considered experimental and is not yet fully tested.**
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bundle add rodauth_phlex
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
gem install rodauth_phlex
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
In your Roda app Rodauth configuration, disable `render` and enable the `phlex` plugin:
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
require "rodauth_phlex"
|
|
32
|
+
|
|
33
|
+
class MyApp < Roda
|
|
34
|
+
# We need to the roda phlex plugin as well.
|
|
35
|
+
plugin :phlex
|
|
36
|
+
|
|
37
|
+
plugin :rodauth, render: false do
|
|
38
|
+
enable :phlex
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Configuration
|
|
44
|
+
|
|
45
|
+
* `phlex_views_namespace` : The namespace to use for views. Default is `"RodauthPhlex::Views"`.
|
|
46
|
+
* `phlex_components_namespace` : The namespace to use for components. Default is `"RodauthPhlex::Components"`.
|
|
47
|
+
* `phlex_email_namespace` : The namespace to use for email templates. Default is `"RodauthPhlex::Emails"`.
|
|
48
|
+
* `phlex_layout_class` : The layout class to use for components. Default is `RodauthPhlex::Undefined`, no additional Layout used.
|
|
49
|
+
* `phlex_layout_title_key` : The key to use for the title in the layout. Default is `title`. Set to `false` or `nil` to disable setting the title.
|
|
50
|
+
* `phlex_set_page_title(title, opts)` : Custom method to set the page title. Where `title` is the string provided by Rodauth und `opts` is the `phlex_layout_opts` options hash.
|
|
51
|
+
* `phlex_classify_page(page_name, mode)` : Custom method to classify the page name. Where `page_name` is the template name provided by Rodauth and `mode` is either `:view` or `:render`.
|
|
52
|
+
|
|
53
|
+
## Under the hood
|
|
54
|
+
|
|
55
|
+
The plugin overrides the `render` and `view` method to use Phlex views and components instead of the built-in templates.
|
|
56
|
+
|
|
57
|
+
### Template to Class mapping
|
|
58
|
+
|
|
59
|
+
An original `foo-bar.str` template is translated into either `RodauthPhlex::Components::FooBar` or `RodauthPhlex::Views::FooBar` class, depending on the context where the template is used:
|
|
60
|
+
|
|
61
|
+
* When `view` is called with a template name, the `RodauthPhlex::Views` namespace is used.
|
|
62
|
+
Optionally, the `phlex_layout` is set to the configured `phlex_layout_class`
|
|
63
|
+
* When `render` is called with a template name, the `RodauthPhlex::Components` namespace.
|
|
64
|
+
If the class is not found, it will look in the `RodauthPhlex::Views` namespace and emit a warning to also provide a `RodauthPhlex::Components` class. This is to allow for views to have additional layout to their components.
|
|
65
|
+
Regardless of the used class, no layout is used (`phlex_layout(false)`).
|
|
66
|
+
|
|
67
|
+
The original `baz-qux-email.str` templates are translated into `RodauthPhlex::Emails::BazQuxEmail` class.
|
|
68
|
+
|
|
69
|
+
### Email templates
|
|
70
|
+
|
|
71
|
+
Email templates are currently supposed to emit plain text for use with the `mail` gem.
|
|
72
|
+
They subclass `RodauthPhlex::Email`, which provides helper methods to render plain text lines. (Which is currently a big hack.)
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
77
|
+
|
|
78
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/fnordfish/rodauth_phlex>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fnordfish/rodauth_phlex/blob/main/CODE_OF_CONDUCT.md).
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
87
|
+
|
|
88
|
+
## Code of Conduct
|
|
89
|
+
|
|
90
|
+
Everyone interacting in the RodauthPhlex project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fnordfish/rodauth_phlex/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex
|
|
4
|
+
class Component < Phlex::HTML
|
|
5
|
+
def initialize(rodauth)
|
|
6
|
+
@rodauth = rodauth
|
|
7
|
+
end
|
|
8
|
+
attr_reader :rodauth
|
|
9
|
+
|
|
10
|
+
# only to be used for rodauth html helper method output
|
|
11
|
+
def safe_html(str)
|
|
12
|
+
raw(safe(str)) if str
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/add-recovery-codes.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class AddRecoveryCodes < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
pre(id: "recovery-codes") do
|
|
13
|
+
plain rodauth.recovery_codes.join("\n\n")
|
|
14
|
+
end
|
|
15
|
+
if rodauth.can_add_recovery_codes?
|
|
16
|
+
safe_html rodauth.add_recovery_codes_heading
|
|
17
|
+
RecoveryCodes()
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/button.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class Button < RodauthPhlex::Component
|
|
11
|
+
def initialize(rodauth, value, opts = {})
|
|
12
|
+
super(rodauth)
|
|
13
|
+
|
|
14
|
+
@value = value
|
|
15
|
+
@opts = opts
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr_reader :value, :opts
|
|
19
|
+
|
|
20
|
+
def view_template(&block)
|
|
21
|
+
div(class: "form-group mb-3") do
|
|
22
|
+
if block_given?
|
|
23
|
+
button(type: "submit", name: opts[:name], class: btn_class) { yield }
|
|
24
|
+
end
|
|
25
|
+
input(type: "submit", name: opts[:name], class: btn_class, value: value)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def btn_class
|
|
30
|
+
opts[:class] || "btn btn-primary"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/change-login.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class ChangeLogin < Rodauth::Component
|
|
11
|
+
def view_template
|
|
12
|
+
form(method: "post", class: "rodauth", role: "form", id: "change-login-form") do
|
|
13
|
+
safe_html rodauth.change_login_additional_form_tags
|
|
14
|
+
safe_html rodauth.csrf_tag
|
|
15
|
+
LoginField(rodauth)
|
|
16
|
+
LoginConfirmField(rodauth) if rodauth.require_login_confirmation?
|
|
17
|
+
PasswordField(rodauth) if rodauth.change_login_requires_password?
|
|
18
|
+
Button(rodauth, rodauth.change_login_button)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/email-auth-request-form.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class EmailAuthRequestForm < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
form(action: rodauth.email_auth_request_path, method: "post", class: "rodauth", role: "form", id: "email-auth-request-form") do
|
|
13
|
+
safe_html rodauth.email_auth_request_additional_form_tags
|
|
14
|
+
safe_html rodauth.csrf_tag(rodauth.email_auth_request_path)
|
|
15
|
+
LoginHiddenField(rodauth)
|
|
16
|
+
Button(rodauth, rodauth.email_auth_request_button)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth `Rodauth::Base#formatted_field_error(field)`:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/lib/rodauth/features/base.rb
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class FormattedFieldError < RodauthPhlex::Component
|
|
11
|
+
def initialize(rodauth, field)
|
|
12
|
+
super(rodauth)
|
|
13
|
+
@field = field
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def view_template
|
|
17
|
+
field = @field
|
|
18
|
+
error = field_error(field)
|
|
19
|
+
return unless error
|
|
20
|
+
span(class: rodauth.input_field_error_message_class, id: "#{field}_error_message") { error }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/global-logout-field.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class GlobalLogoutField < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
div(class: "form-group mb-3") do
|
|
13
|
+
div(class: "form-check checkbox") do
|
|
14
|
+
input(type: "checkbox", name: rodauth.global_logout_param, class: "form-check-input", id: "global-logout", value: "t")
|
|
15
|
+
label(class: "rodauth-global-logout-label form-check-label", for: "global-logout") { rodauth.global_logout_label }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth `Rodauth::Base#input_field_string(param, id, opts={})`:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/lib/rodauth/features/base.rb
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class InputField < RodauthPhlex::Component
|
|
11
|
+
def initialize(rodauth, param, id, opts = {})
|
|
12
|
+
super(rodauth)
|
|
13
|
+
@param = param
|
|
14
|
+
@id = id
|
|
15
|
+
@opts = opts
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr_reader :param, :id, :opts
|
|
19
|
+
|
|
20
|
+
def view_template
|
|
21
|
+
input(**args)
|
|
22
|
+
unless opts[:skip_error_message]
|
|
23
|
+
whitespace
|
|
24
|
+
FormattedFieldError(rodauth, param)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def args
|
|
29
|
+
args = {}
|
|
30
|
+
if (attr = opts[:attr])
|
|
31
|
+
if attr.is_a?(Hash)
|
|
32
|
+
args.merge!(attr)
|
|
33
|
+
else
|
|
34
|
+
warn "The `:attr` option should be a Hash. Ignored '#{attr}'."
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
args[:autocomplete] = opts[:autocomplete] if rodauth.autocomplete_for_field?(param)
|
|
39
|
+
args[:inputmode] = opts[:inputmode] if rodauth.inputmode_for_field?(param)
|
|
40
|
+
args[:required] = opts[:required] if rodauth.mark_input_fields_as_required?
|
|
41
|
+
|
|
42
|
+
if (attr = rodauth.field_attributes(param)) && !attr.empty?
|
|
43
|
+
if attr.is_a?(Hash)
|
|
44
|
+
args.merge!(attr)
|
|
45
|
+
else
|
|
46
|
+
warn "The `field_attributes`/`default_field_attributes` should be a Hash. Ignored '#{attr}'."
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if (attr = rodauth.field_error_attributes(param))
|
|
51
|
+
if attr.is_a?(Hash)
|
|
52
|
+
args.merge!(attr)
|
|
53
|
+
else
|
|
54
|
+
warn "The `field_error_attributes` should be a Hash. Ignored '#{attr}'."
|
|
55
|
+
end
|
|
56
|
+
else
|
|
57
|
+
args[:aria_invalid] = "true"
|
|
58
|
+
args[:aria_describedby] = "#{param}_error_message"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
args[:type] = type = opts.fetch(:type, "text")
|
|
62
|
+
args[:class] = [opts.fetch(:class, "form-control"), rodauth.add_field_error_class(param)]
|
|
63
|
+
args[:name] = param
|
|
64
|
+
args[:id] = id
|
|
65
|
+
args[:value] = if type == "password"
|
|
66
|
+
""
|
|
67
|
+
else
|
|
68
|
+
opts.fetch(:value) { rodauth.param(param) }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
args
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/login-confirm-field.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginConfirmField < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
div(class: "form-group mb-3") do
|
|
13
|
+
label(for: "login-confirm", class: "form-label") { "#{rodauth.login_confirm_label}#{rodauth.input_field_label_suffix}" }
|
|
14
|
+
InputField(rodauth, rodauth.login_confirm_param, "login-confirm", type: rodauth.login_input_type, autocomplete: rodauth.login_uses_email? ? "email" : "on")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/login-display.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginDisplay < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
div(class: "form-group mb-3") do
|
|
13
|
+
LoginHiddenField(rodauth)
|
|
14
|
+
label(for: "login", class: "form-label") { rodauth.login_label }
|
|
15
|
+
div(class: "form-control-plaintext form-control-static") { rodauth.param(rodauth.login_param) }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/login-field.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginField < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
div(class: "form-group mb-3") do
|
|
13
|
+
label(for: "login", class: "form-label") { "#{rodauth.login_label}#{rodauth.input_field_label_suffix}" }
|
|
14
|
+
InputField(rodauth, rodauth.login_param, "login", type: rodauth.login_input_type, autocomplete: rodauth.login_field_autocomplete_value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/login-form.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginForm < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
form(method: "post", class: "rodauth", role: "form", id: "login-form") do
|
|
13
|
+
safe_html rodauth.login_additional_form_tags
|
|
14
|
+
safe_html rodauth.csrf_tag
|
|
15
|
+
if rodauth.skip_login_field_on_login?
|
|
16
|
+
render LoginDisplay(rodauth)
|
|
17
|
+
else
|
|
18
|
+
render LoginField(rodauth)
|
|
19
|
+
end
|
|
20
|
+
render PasswordField(rodauth) unless rodauth.skip_password_field_on_login?
|
|
21
|
+
Button(rodauth, rodauth.login_button)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/login-form-footer.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginFormFooter < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
safe_html rodauth.login_form_footer_links_heading
|
|
13
|
+
ul(class: "rodauth-links rodauth-login-footer-links") do
|
|
14
|
+
rodauth.login_form_footer_links.each do |_, link, text|
|
|
15
|
+
li { a(href: link) { text } }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth `Rodauth::Login#login_hidden_field()`:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/lib/rodauth/features/login.rb
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class LoginHiddenField < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
login_param = rodauth.login_param
|
|
13
|
+
input(type: "hidden", name: login_param, value: rodauth.param(login_param))
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RodauthPhlex::Components
|
|
4
|
+
# This is a Phlex version of the Rodauth template:
|
|
5
|
+
# https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/otp-auth-code-field.str
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2024 Robert Schulze
|
|
8
|
+
# Copyright (c) 2015-2023 Jeremy Evans
|
|
9
|
+
# MIT License
|
|
10
|
+
class OtpAuthCodeField < RodauthPhlex::Component
|
|
11
|
+
def view_template
|
|
12
|
+
div(class: "form-group mb-3") do
|
|
13
|
+
label(for: "otp-auth-code", class: "form-label") { "#{rodauth.otp_auth_label}#{rodauth.input_field_label_suffix}" }
|
|
14
|
+
div(class: "row") do
|
|
15
|
+
div(class: "col-sm-3") do
|
|
16
|
+
InputField(rodauth, rodauth.otp_auth_param, "otp-auth-code", type: "text", value: "", autocomplete: "off", inputmode: "numeric")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|