Compare commits
No commits in common. "main" and "1.2.0" have entirely different histories.
|
|
@ -5,7 +5,6 @@ async function loadData (block) {
|
|||
const response = await fetch (source);
|
||||
if (response.ok) {
|
||||
const items = await response.json();
|
||||
var itemLoaders = [];
|
||||
|
||||
if (Array.isArray (items)) {
|
||||
const template = block.querySelector ("template");
|
||||
|
|
@ -13,25 +12,15 @@ async function loadData (block) {
|
|||
tableBody.innerHTML = "";
|
||||
items.forEach (item => {
|
||||
const clone = template.content.cloneNode (true);
|
||||
const loader = window["populate" + block.dataset.item] (clone, item);
|
||||
if (loader != null) {
|
||||
itemLoaders.push (loader);
|
||||
}
|
||||
window["populate" + block.dataset.item] (clone, item);
|
||||
tableBody.appendChild (clone);
|
||||
tableBody.lastElementChild.dataset.itemid = item.id;
|
||||
});
|
||||
} else {
|
||||
const loader = window["populate" + block.dataset.item] (block, items);
|
||||
if (loader != null) {
|
||||
itemLoaders.push (loader);
|
||||
}
|
||||
window["populate" + block.dataset.item] (block, items);
|
||||
}
|
||||
|
||||
block.classList.add ("loaded");
|
||||
|
||||
for (const loader of itemLoaders) {
|
||||
await loader();
|
||||
}
|
||||
} else {
|
||||
if ((response.status == 401) || (response.status == 403)) {
|
||||
document.location.href = document.body.dataset.baseurl;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
Welcome to #(host).
|
||||
Välkommen till #(host).
|
||||
|
||||
To activate your account, go to #baseURL/auth/password/#(token) and enter a password.
|
||||
|
||||
The link is valid until #date(expiration, "yyyy-MM-dd HH:mm (z)").
|
||||
För att aktivera ditt konto, gå till #baseURL/auth/password/#(token) och skriv in ett lösenord.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
You have requested a new password on #(host).
|
||||
Du har begärt ett nytt lösenord på #(host).
|
||||
|
||||
To change your password, go to #baseURL/auth/password/#(token) and enter a password.
|
||||
|
||||
The link is valid until #date(expiration, "yyyy-MM-dd HH:mm (z)").
|
||||
För att ändra ditt lösenord, gå till #baseURL/auth/password/#(token) och skriv in ett lösenord.
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public struct AdminController<User: ManagedUser>: Sendable where User.SessionID
|
|||
let token = try await UserToken.create (connection: connection).token
|
||||
try await User.create (email: invitation.email, fullname: invitation.fullname, roles: invitation.roles, token: token, on: connection)
|
||||
let host = try Environment.baseURL.host() ?? ""
|
||||
let body = try await request.view.render ("email/invite", AuthenticationController<User>.TokenEmailContext (token: token, host: host, expiration: Calendar.current.date (byAdding: .day, value: 1, to: Date()) ?? Date()))
|
||||
let body = try await request.view.render ("email/invite", ["token": token, "host": host])
|
||||
.data
|
||||
let message = Email (sender: Email.Contact (emailAddress: try Environment.emailSender),
|
||||
recipients: [Email.Contact(emailAddress: invitation.email)],
|
||||
|
|
|
|||
|
|
@ -91,12 +91,6 @@ public struct AuthenticationController<User: ManagedUser>: Sendable where User.S
|
|||
let email: String
|
||||
}
|
||||
|
||||
struct TokenEmailContext: Encodable {
|
||||
let token: String
|
||||
let host: String
|
||||
let expiration: Date
|
||||
}
|
||||
|
||||
func forgotPassword (request: Request) async throws -> Response {
|
||||
|
||||
let input = try request.content.decode (Input.self)
|
||||
|
|
@ -107,7 +101,7 @@ public struct AuthenticationController<User: ManagedUser>: Sendable where User.S
|
|||
let token = try await UserToken.create (connection: connection).token
|
||||
try await User.store (token: token, userId: user.id, on: connection)
|
||||
let host = try Environment.baseURL.host() ?? ""
|
||||
let body = try await request.view.render ("email/reset", TokenEmailContext (token: token, host: host, expiration: Calendar.current.date (byAdding: .hour, value: 1, to: Date()) ?? Date()))
|
||||
let body = try await request.view.render ("email/reset", ["token": token, "host": host, "section": "login"])
|
||||
.data
|
||||
let message = Email (sender: Email.Contact (emailAddress: try Environment.emailSender),
|
||||
recipients: [Email.Contact(emailAddress: input.email)],
|
||||
|
|
|
|||
|
|
@ -4,22 +4,14 @@ import FluentPostgresDriver
|
|||
import SwiftSMTPVapor
|
||||
|
||||
public struct ManageableUsers {
|
||||
public static func configure (_ app: Application,
|
||||
mainMenu: [MenuItem] = [],
|
||||
homePageName: String = "Home",
|
||||
userAdminPageName: String = "User Administration",
|
||||
maxConnectionsPerEventLoop: Int = 1,
|
||||
connectionPoolTimeout: TimeAmount = .seconds(10),
|
||||
sqlLogLevel: Logger.Level = .debug) async throws {
|
||||
app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init (hostname: Environment.get("DATABASE_HOST") ?? "localhost",
|
||||
port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? SQLPostgresConfiguration.ianaPortNumber,
|
||||
username: Environment.get("DATABASE_USERNAME") ?? "sampleapp",
|
||||
password: Environment.get("DATABASE_PASSWORD") ?? "sampleapp_password",
|
||||
database: Environment.get("DATABASE_NAME") ?? "sampleapp",
|
||||
tls: .prefer(try .init(configuration: .clientDefault))),
|
||||
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
|
||||
connectionPoolTimeout: connectionPoolTimeout,
|
||||
sqlLogLevel: sqlLogLevel
|
||||
public static func configure (_ app: Application, mainMenu: [MenuItem] = [], homePageName: String = "Home", userAdminPageName: String = "User Administration") async throws {
|
||||
app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init(
|
||||
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
|
||||
port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? SQLPostgresConfiguration.ianaPortNumber,
|
||||
username: Environment.get("DATABASE_USERNAME") ?? "sampleapp",
|
||||
password: Environment.get("DATABASE_PASSWORD") ?? "sampleapp_password",
|
||||
database: Environment.get("DATABASE_NAME") ?? "sampleapp",
|
||||
tls: .prefer(try .init(configuration: .clientDefault)))
|
||||
), as: .psql)
|
||||
|
||||
_ = try Environment.baseURL
|
||||
|
|
|
|||
Loading…
Reference in New Issue