dynamic rbac and roles
This commit is contained in:
@@ -31,7 +31,6 @@ pub(crate) async fn register(
|
||||
email: input.email.trim().to_string(),
|
||||
password: input.password.trim().to_string(),
|
||||
password_confirmation: input.password_confirmation.trim().to_string(),
|
||||
role: input.role.trim().to_string(),
|
||||
timezone: timezone.clone(),
|
||||
phone_country: phone_country.clone(),
|
||||
}))
|
||||
|
||||
@@ -12,8 +12,6 @@ pub(crate) struct RegisterInput {
|
||||
#[serde(default)]
|
||||
pub password_confirmation: String,
|
||||
#[serde(default)]
|
||||
pub role: String,
|
||||
#[serde(default)]
|
||||
pub timezone: String,
|
||||
#[serde(default)]
|
||||
pub phone_country: String,
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
//! The client filters these itself as the field is typed into; here the lists
|
||||
//! ship whole in `<datalist>` elements and the browser does the filtering.
|
||||
|
||||
pub(crate) const ROLES: &[&str] = &["admin", "moderator", "accountant", "viewer"];
|
||||
|
||||
pub(crate) fn timezones() -> Vec<String> {
|
||||
jiff::tz::db()
|
||||
.available()
|
||||
|
||||
@@ -12,7 +12,6 @@ use super::suggestions;
|
||||
#[template(path = "pages/register/register.html")]
|
||||
struct RegisterPage {
|
||||
nav: Nav,
|
||||
roles: &'static [&'static str],
|
||||
timezones: Vec<String>,
|
||||
phone_countries: Vec<String>,
|
||||
}
|
||||
@@ -20,7 +19,6 @@ struct RegisterPage {
|
||||
pub(crate) fn render_page(nav: Nav) -> String {
|
||||
render(&RegisterPage {
|
||||
nav,
|
||||
roles: suggestions::ROLES,
|
||||
timezones: suggestions::timezones(),
|
||||
phone_countries: suggestions::phone_countries(),
|
||||
})
|
||||
|
||||
@@ -13,14 +13,13 @@
|
||||
<label>Password <span>(optional)</span><input name="password" type="password" autocomplete="new-password"></label>
|
||||
<label>Confirm password<input name="password_confirmation" type="password" autocomplete="new-password"></label>
|
||||
{#
|
||||
The three fields the client offers suggestions for. A datalist keeps the
|
||||
The two fields the client offers suggestions for. A datalist keeps the
|
||||
lists open — the backend, not this form, decides what is accepted — while
|
||||
still showing the same choices the client's suggestion popup does.
|
||||
|
||||
There is no role field: everyone registers as `guest` and an admin
|
||||
assigns a real role afterwards.
|
||||
#}
|
||||
<label>Role<input name="role" list="role-options" autocomplete="off"></label>
|
||||
<datalist id="role-options">
|
||||
{% for role in roles %}<option value="{{ role }}"></option>{% endfor %}
|
||||
</datalist>
|
||||
<label>Timezone<input name="timezone" list="timezone-options" autocomplete="off" placeholder="Europe/Bratislava"></label>
|
||||
<datalist id="timezone-options">
|
||||
{% for timezone in timezones %}<option value="{{ timezone }}"></option>{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user