Commit 41bc4261 authored by Nicolas Pernoud's avatar Nicolas Pernoud
Browse files

feat: added email field to users

parent 7586f11d
Pipeline #7212 passed with stages
in 2 minutes and 47 seconds
......@@ -2,6 +2,7 @@
{
"id": "1",
"login": "admin",
"email": "nicolas@vestibule.127.0.0.1.nip.io",
"memberOf": [
"ADMINS"
],
......
......@@ -27,6 +27,7 @@ type User struct {
ID string `json:"id,omitempty"`
Login string `json:"login"`
DisplayName string `json:"displayName,omitempty"`
Email string `json:"email,omitempty"`
Roles []string `json:"memberOf"`
IsAdmin bool `json:"isAdmin,omitempty"`
Name string `json:"name,omitempty"`
......
......@@ -48,7 +48,7 @@ func (m Manager) HandleInMemoryLogin(w http.ResponseWriter, r *http.Request) {
http.Error(w, "error generating XSRF Token", 500)
return
}
tokenData := TokenData{User: User{ID: user.ID, Login: user.Login, Roles: user.Roles}, XSRFToken: xsrfToken}
tokenData := TokenData{User: User{ID: user.ID, Login: user.Login, Email: user.Email, Roles: user.Roles}, XSRFToken: xsrfToken}
tokens.Manager.StoreData(tokenData, m.Hostname, authTokenKey, 24*time.Hour, w)
// Log the connexion
log.Logger.Printf("| %v (%v %v) | Login success | %v | %v", user.Login, user.Name, user.Surname, r.RemoteAddr, log.GetCityAndCountryFromRequest(r))
......
......@@ -12,6 +12,7 @@ let password_field;
let passwordhash_field;
let name_field;
let surname_field;
let email_field;
let roles_field;
// local variables
......@@ -31,6 +32,7 @@ export async function mount(where) {
<th>Hash</th>
<th>Name</th>
<th>Surname</th>
<th>Email</th>
<th>Roles</th>
<th>Actions</th>
</tr>
......@@ -95,6 +97,12 @@ export async function mount(where) {
<input class="input" type="text" id="users-modal-surname" />
</div>
</div>
<div class="field" id="users-modal-email-container">
<label class="label">Email</label>
<div class="control">
<input class="input" type="email" id="users-modal-email" />
</div>
</div>
<div class="field" id="users-modal-roles-container">
<label class="label">Roles (separated with commas)</label>
<div class="control">
......@@ -115,7 +123,7 @@ export async function mount(where) {
}
function cleanUser(user) {
let props = ["password", "name", "surname", "memberOf"];
let props = ["password", "name", "surname", "email", "memberOf"];
for (const prop of props) {
user[prop] = user[prop] === undefined ? "" : user[prop];
}
......@@ -131,6 +139,7 @@ function userTemplate(user) {
<td>${user.passwordHash === undefined ? "" : "..."}</td>
<td>${user.name}</td>
<td>${user.surname}</td>
<td>${user.email}</td>
<td>${user.memberOf}</td>
<td>
<a id="users-user-edit-${user.id}" class="button is-link is-small">
......@@ -208,6 +217,7 @@ function registerModalFields() {
passwordhash_field = document.getElementById("users-modal-passwordhash");
name_field = document.getElementById("users-modal-name");
surname_field = document.getElementById("users-modal-surname");
email_field = document.getElementById("users-modal-email");
roles_field = document.getElementById("users-modal-roles");
document.getElementById(`users-modal-close`).addEventListener("click", function () {
toggleModal();
......@@ -234,6 +244,7 @@ async function editUser(user) {
passwordhash_field.value = user.passwordHash;
name_field.value = user.name;
surname_field.value = user.surname;
email_field.value = user.email;
roles_field.value = user.memberOf;
toggleModal();
}
......@@ -250,6 +261,7 @@ async function newUser() {
passwordhash_field.value = "";
name_field.value = "";
surname_field.value = "";
email_field.value = "";
roles_field.value = "";
toggleModal();
}
......@@ -268,6 +280,7 @@ async function postUser() {
passwordHash: passwordhash_field.value,
name: name_field.value,
surname: surname_field.value,
email: email_field.value,
memberOf: roles_field.value.split(","),
}),
});
......
......@@ -32,7 +32,7 @@
<div class="navbar-brand">
<div class="navbar-item">
<a class="button is-primary is-rounded is-outlined" href="https://www.github.com/nicolaspernoud/Vestibule" target="_blank" rel="noopener noreferrer">
<span>4.3.45</span>
<span>4.3.46</span>
<span class="icon">
<svg
class="svg-inline--fa fa-github fa-w-16"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment