()
let data = ctx.Data
- let! tryUser = data.WebLogUser.FindByEmail model.EmailAddress ctx.WebLog.Id
+ let! tryUser = data.WebLogUser.FindByEmail (model.EmailAddress.ToLowerInvariant()) ctx.WebLog.Id
match! verifyPassword tryUser model.Password ctx with
| Ok _ ->
let user = tryUser.Value
diff --git a/src/MyWebLog/Maintenance.fs b/src/MyWebLog/Maintenance.fs
index 43caaca..c49c5d5 100644
--- a/src/MyWebLog/Maintenance.fs
+++ b/src/MyWebLog/Maintenance.fs
@@ -20,33 +20,31 @@ let private doCreateWebLog (args: string[]) (sp: IServiceProvider) = task {
| true, ianaId -> ianaId
| false, _ -> raise <| TimeZoneNotFoundException $"Cannot find IANA timezone for {local}"
- // Create the web log
- let webLogId = WebLogId.Create()
- let userId = WebLogUserId.Create()
- let homePageId = PageId.Create()
- let slug = Handlers.Upload.makeSlug args[2]
-
// If this is the first web log being created, the user will be an installation admin; otherwise, they will be an
// admin just over their web log
let! webLogs = data.WebLog.All()
let accessLevel = if List.isEmpty webLogs then Administrator else WebLogAdmin
-
- do! data.WebLog.Add
- { WebLog.Empty with
- Id = webLogId
- Name = args[2]
- Slug = slug
- UrlBase = args[1]
- DefaultPage = string homePageId
- TimeZone = timeZone }
+
+ let homePageId = PageId.Create()
+
+ // Create the web log
+ let webLog =
+ { WebLog.Empty with
+ Id = WebLogId.Create()
+ Name = args[2]
+ Slug = Handlers.Upload.makeSlug args[2]
+ UrlBase = args[1].ToLowerInvariant()
+ DefaultPage = string homePageId
+ TimeZone = timeZone }
+ do! data.WebLog.Add webLog
// Create the admin user
let now = Noda.now ()
let user =
{ WebLogUser.Empty with
- Id = userId
- WebLogId = webLogId
- Email = args[3]
+ Id = WebLogUserId.Create()
+ WebLogId = webLog.Id
+ Email = args[3].ToLowerInvariant()
FirstName = "Admin"
LastName = "User"
PreferredName = "Admin"
@@ -58,8 +56,8 @@ let private doCreateWebLog (args: string[]) (sp: IServiceProvider) = task {
do! data.Page.Add
{ Page.Empty with
Id = homePageId
- WebLogId = webLogId
- AuthorId = userId
+ WebLogId = webLog.Id
+ AuthorId = user.Id
Title = "Welcome to myWebLog!"
Permalink = Permalink "welcome-to-myweblog.html"
PublishedOn = now
@@ -70,11 +68,11 @@ let private doCreateWebLog (args: string[]) (sp: IServiceProvider) = task {
Text = Html "This is your default home page.
" }
] }
- printfn $"Successfully initialized database for {args[2]} with URL base {args[1]}"
+ printfn $"Successfully initialized database for {webLog.Name} with URL base {webLog.UrlBase}"
match accessLevel with
- | Administrator -> printfn $" ({args[3]} is an installation administrator)"
+ | Administrator -> printfn $" ({user.Email} is an installation administrator)"
| WebLogAdmin ->
- printfn $" ({args[3]} is a web log administrator;"
+ printfn $" ({user.Email} is a web log administrator;"
printfn """ use "upgrade-user" to promote to installation administrator)"""
| _ -> ()
}
@@ -422,8 +420,9 @@ module Backup =
/// Generate a backup archive
let generateBackup (args: string[]) (sp: IServiceProvider) = task {
if args.Length > 1 && args.Length < 5 then
+ let url = args[1].ToLowerInvariant()
let data = sp.GetRequiredService()
- match! data.WebLog.FindByHost args[1] with
+ match! data.WebLog.FindByHost url with
| Some webLog ->
let fileName =
if args.Length = 2 || (args.Length = 3 && args[2] = "pretty") then
@@ -434,7 +433,7 @@ module Backup =
$"{args[2]}.json"
let prettyOutput = (args.Length = 3 && args[2] = "pretty") || (args.Length = 4 && args[3] = "pretty")
do! createBackup webLog fileName prettyOutput data
- | None -> eprintfn $"Error: no web log found for {args[1]}"
+ | None -> eprintfn $"Error: no web log found for {url}"
else
eprintfn """Usage: myWebLog backup [url-base] [*backup-file-name] [**"pretty"]"""
eprintfn """ * optional - default is [web-log-slug].json"""
@@ -445,7 +444,7 @@ module Backup =
let restoreFromBackup (args: string[]) (sp: IServiceProvider) = task {
if args.Length = 2 || args.Length = 3 then
let data = sp.GetRequiredService()
- let newUrlBase = if args.Length = 3 then Some args[2] else None
+ let newUrlBase = if args.Length = 3 then Some (args[2].ToLowerInvariant()) else None
do! restoreBackup args[1] newUrlBase (args[0] <> "do-restore") true data
else
eprintfn "Usage: myWebLog restore [backup-file-name] [*url-base]"
@@ -472,7 +471,7 @@ let private doUserUpgrade urlBase email (data: IData) = task {
/// Upgrade a WebLogAdmin user to an Administrator user if the command-line arguments are good
let upgradeUser (args: string[]) (sp: IServiceProvider) = task {
match args.Length with
- | 3 -> do! doUserUpgrade args[1] args[2] (sp.GetRequiredService())
+ | 3 -> do! doUserUpgrade (args[1].ToLowerInvariant()) (args[2].ToLowerInvariant()) (sp.GetRequiredService())
| _ -> eprintfn "Usage: myWebLog upgrade-user [web-log-url-base] [email-address]"
}
@@ -491,6 +490,8 @@ let doSetPassword urlBase email password (data: IData) = task {
/// Set a user's password if the command-line arguments are good
let setPassword (args: string[]) (sp: IServiceProvider) = task {
match args.Length with
- | 4 -> do! doSetPassword args[1] args[2] args[3] (sp.GetRequiredService())
+ | 4 ->
+ do! doSetPassword
+ (args[1].ToLowerInvariant()) (args[2].ToLowerInvariant()) args[3] (sp.GetRequiredService())
| _ -> eprintfn "Usage: myWebLog set-password [web-log-url-base] [email-address] [password]"
}
diff --git a/src/MyWebLog/MyWebLog.fsproj b/src/MyWebLog/MyWebLog.fsproj
index 227afcb..9bb4bce 100644
--- a/src/MyWebLog/MyWebLog.fsproj
+++ b/src/MyWebLog/MyWebLog.fsproj
@@ -31,13 +31,13 @@
-
-
-
+
+
+
-
+
diff --git a/src/MyWebLog/Program.fs b/src/MyWebLog/Program.fs
index 32abcdc..4dc7880 100644
--- a/src/MyWebLog/Program.fs
+++ b/src/MyWebLog/Program.fs
@@ -218,8 +218,9 @@ let main args =
// Load admin and default themes, and all themes in the /themes directory
do! Maintenance.loadTheme [| ""; "./admin-theme.zip" |] app.Services
do! Maintenance.loadTheme [| ""; "./default-theme.zip" |] app.Services
- if Directory.Exists "./themes" then
- for themeFile in Directory.EnumerateFiles("./themes", "*-theme.zip") do
+ let themePath = Path.Combine(".", "themes")
+ if Directory.Exists themePath then
+ for themeFile in Directory.EnumerateFiles(themePath, "*-theme.zip") do
do! Maintenance.loadTheme [| ""; themeFile |] app.Services
let _ = app.UseForwardedHeaders()
diff --git a/src/MyWebLog/appsettings.json b/src/MyWebLog/appsettings.json
index cad98ac..207a6c5 100644
--- a/src/MyWebLog/appsettings.json
+++ b/src/MyWebLog/appsettings.json
@@ -1,5 +1,5 @@
{
- "Generator": "myWebLog 2.1.1",
+ "Generator": "myWebLog 2.2",
"Logging": {
"LogLevel": {
"MyWebLog.Handlers": "Information"
diff --git a/src/admin-theme/version.txt b/src/admin-theme/version.txt
index d23a661..f3f14b6 100644
--- a/src/admin-theme/version.txt
+++ b/src/admin-theme/version.txt
@@ -1,2 +1,2 @@
myWebLog Admin
-2.1.1
\ No newline at end of file
+2.2
\ No newline at end of file
diff --git a/src/default-theme/version.txt b/src/default-theme/version.txt
index dccf21b..d57272f 100644
--- a/src/default-theme/version.txt
+++ b/src/default-theme/version.txt
@@ -1,2 +1,2 @@
myWebLog Default Theme
-2.1.1
\ No newline at end of file
+2.2
\ No newline at end of file