diff --git a/Sources/App/Controllers/cntrlUser.swift b/Sources/App/Controllers/cntrlUser.swift index bc0d923..9d06cb0 100644 --- a/Sources/App/Controllers/cntrlUser.swift +++ b/Sources/App/Controllers/cntrlUser.swift @@ -12,12 +12,24 @@ struct cntrlUser: RouteCollection { func boot(routes: RoutesBuilder) throws { let rts = routes.grouped("users") rts.get(use: index) + rts.get(":userid", ":password", use: login) rts.post(use: create) rts.put(use: update) rts.group(":id") { todo in rts.delete(use: delete) } } + + func login(req: Request) async throws -> mdlUser{ + try await mdlUser.query(on: req.db) + .with(\.$roles) + .with(\.$division) + .with(\.$gate) + .with(\.$location) + .filter(\.$username == req.parameters.get("userid")) + .filter( \.$password == req.parameters.get("password")) + .first()! + } func index(req: Request) async throws -> [mdlUser] { try await mdlUser.query(on: req.db).with(\.$roles).all() diff --git a/Sources/App/Models/BaseTables/mdlLocation.swift b/Sources/App/Models/BaseTables/mdlLocation.swift index e5334ef..0028884 100644 --- a/Sources/App/Models/BaseTables/mdlLocation.swift +++ b/Sources/App/Models/BaseTables/mdlLocation.swift @@ -22,7 +22,7 @@ final class mdlLocation: Model, Content { @Field(key: "postalCode") var postalcode: String? @Field(key: "dealerCode") var dealercode: String? @Field(key: "fileLocation") var filelocation: String? - @Field(key: "isAcrtive") var isactive: Bool? + @Field(key: "isActive") var isactive: Bool? @Parent(key: "stateId") var state: mdlState @OptionalParent(key: "unitId") var unit: mdlUnit?