Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Bug Fixes, Fixed Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
chandlerhuff committed Nov 2, 2017
1 parent 716ee1c commit 00f6948
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/Server/Middleware/AuthenicationMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension Request {
guard Date() < tokenExpiration else { return nil }
guard let userId = accessToken["userId"] as? ObjectId else { return nil }
storage["userId"] = userId
return accessToken["userId"] as? ObjectId
return userId
} catch {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Server/Models/AccessToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct AccessToken {
let token = try String.tokenEncoded()
let tokenHash = try Application.makeHash(token)
accessToken["tokenExpires"] = Date(timeIntervalSinceNow: AccessToken.expiresIn)
accessToken["endOfLife"] = Date(timeIntervalSinceNow: 1210000 + AccessToken.expiresIn)
accessToken["token"] = tokenHash
try AccessToken.collection.update("_id" == accessTokenId, to: accessToken)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Server/Models/Admin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct Admin {
return document["notificationEmail"] as? String ?? Constants.defaultEmail
}
set {
document["adminEmail"] = newValue
document["notificationEmail"] = newValue
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Server/Providers/MongoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ final class MongoProvider: Vapor.Provider {

let host = mongo["host"]?.string ?? "localhost"
let port = mongo["port"]?.int ?? 27017
if let user = mongo["user"]?.string?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed), user.characters.count > 0 {
if let password = mongo["password"]?.string?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed), password.characters.count > 0 {
if let user = mongo["user"]?.string?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed), user.isEmpty == false {
if let password = mongo["password"]?.string?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed), password.isEmpty == false {
server = try Server("mongodb://\(user):\(password)@\(host):\(port)")
} else {
server = try Server("mongodb://\(user)@\(host):\(port)")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Server/Routes/User+Routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension User {
let protected = group.grouped([authenticationMiddleware])

// MARK: Get Users
group.get { request in
protected.get { request in
let skip = request.data["skip"]?.int ?? 0
let limit = min(100, request.data["limit"]?.int ?? 100)
let documents = try User.collection.find(sortedBy: ["email": .ascending], projecting: [
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- ./Database/configdb:/data/configdb
- ./Database/db:/data/db
vapor:
image: chandlerhuff/vapor:latest
image: bludesign/vapor:latest
restart: always
ports:
- "8080:8080"
Expand Down

0 comments on commit 00f6948

Please sign in to comment.