diff --git a/dub.json b/dub.json index 4f1af98..025223d 100644 --- a/dub.json +++ b/dub.json @@ -4,13 +4,14 @@ "Johannes Loher" ], "dependencies": { - "vibe-d": "~>0.8.0", + "vibe-d": "0.8.1-rc.2", "poodinis": "~>8.0.0" }, "description": "A simple webapplication to edit and view calendar entries", "copyright": "Copyright © 2017, Johannes Loher", "license": "MIT", "versions": [ - "VibeDefaultMain" + "VibeDefaultMain", + "VibeUseOpenSSL11" ] } \ No newline at end of file diff --git a/source/authenticator.d b/source/authenticator.d index 7dceef9..94d48f1 100644 --- a/source/authenticator.d +++ b/source/authenticator.d @@ -7,7 +7,7 @@ import vibe.db.mongo.client : MongoClient; interface Authenticator { - bool checkUser(string username, string password); + bool checkUser(string username, string password) @safe; } class MongoDBAuthenticator : Authenticator @@ -22,7 +22,7 @@ private: string usersCollectionName; public: - bool checkUser(string username, string password) + bool checkUser(string username, string password) @safe { auto users = mongoClient.getCollection(databaseName ~ "." ~ usersCollectionName); auto result = users.findOne(["username" : username, "password" : password]); diff --git a/source/calendarwebapp.d b/source/calendarwebapp.d index 745e5d3..e140e6f 100644 --- a/source/calendarwebapp.d +++ b/source/calendarwebapp.d @@ -26,7 +26,7 @@ import vibe.web.web : errorDisplay, noRoute, redirect, render, SessionVar, { if (!req.session || !req.session.isKeySet("auth")) { - () @trusted{ redirect("/login"); }(); + redirect("/login"); return AuthInfo.init; } return req.session.get!AuthInfo("auth"); @@ -44,7 +44,7 @@ public: render!("login.dt", _error); } - @noAuth @errorDisplay!getLogin void postLogin(string username, string password) + @noAuth @errorDisplay!getLogin void postLogin(string username, string password) @safe { enforce(authenticator.checkUser(username, password), "Benutzername oder Passwort ungültig"); immutable AuthInfo authInfo = {username}; @@ -52,7 +52,7 @@ public: redirect("/"); } - @anyAuth void getLogout() + @anyAuth void getLogout() @safe { terminateSession(); redirect("/"); @@ -64,7 +64,7 @@ public: } @anyAuth @errorDisplay!getCreate void postCreate(Date begin, - Nullable!Date end, string description, string name, EventType type, bool shout) + Nullable!Date end, string description, string name, EventType type, bool shout) @safe { import std.array : replace, split; @@ -79,7 +79,7 @@ public: redirect("/"); } - @anyAuth void postRemove(BsonObjectID id) + @anyAuth void postRemove(BsonObjectID id) @safe { eventStore.removeEvent(id); redirect("/"); diff --git a/source/configuration.d b/source/configuration.d index 7d11e89..b35a584 100644 --- a/source/configuration.d +++ b/source/configuration.d @@ -8,7 +8,7 @@ private: string[string] config; public: - this() + this() const @safe pure nothrow { // dfmt off config = ["Database name" : "CalendarWebapp", @@ -17,7 +17,7 @@ public: // dfmt on } - string get(string key) + string get(string key) const @safe pure nothrow { return config[key]; } diff --git a/source/event.d b/source/event.d index 12f1969..7678f1c 100644 --- a/source/event.d +++ b/source/event.d @@ -13,29 +13,29 @@ import vibe.db.mongo.client : MongoClient; interface EventStore { - Event getEvent(BsonObjectID id); - InputRange!Event getAllEvents(); - void addEvent(Event); - InputRange!Event getEventsBeginningBetween(Date begin, Date end); - void removeEvent(BsonObjectID id); + Event getEvent(BsonObjectID id) @safe; + InputRange!Event getAllEvents() @safe; + void addEvent(Event) @safe; + InputRange!Event getEventsBeginningBetween(Date begin, Date end) @safe; + void removeEvent(BsonObjectID id) @safe; } class MongoDBEventStore : EventStore { public: - Event getEvent(BsonObjectID id) + Event getEvent(BsonObjectID id) @safe { return mongoClient.getCollection(databaseName ~ "." ~ entriesCollectionName) .findOne(["_id" : id]).deserializeBson!Event; } - InputRange!Event getAllEvents() + InputRange!Event getAllEvents() @safe { return mongoClient.getCollection(databaseName ~ "." ~ entriesCollectionName) .find().map!(deserializeBson!Event).inputRangeObject; } - void addEvent(Event event) + void addEvent(Event event) @safe { if (!event.id.valid) event.id = BsonObjectID.generate; @@ -44,7 +44,7 @@ public: .insert(event.serializeToBson); } - InputRange!Event getEventsBeginningBetween(Date begin, Date end) + InputRange!Event getEventsBeginningBetween(Date begin, Date end) @safe { return mongoClient.getCollection(databaseName ~ "." ~ entriesCollectionName) .find(["$and" : [["date" : ["$gte" : begin.serializeToBson]], ["date" @@ -52,7 +52,7 @@ public: .inputRangeObject; } - void removeEvent(BsonObjectID id) + void removeEvent(BsonObjectID id) @safe { mongoClient.getCollection(databaseName ~ "." ~ entriesCollectionName).remove(["_id" : id]); }