Przeglądaj źródła

added login call

main
rpm-mcarman 2 lat temu
rodzic
commit
05eb76f923
2 zmienionych plików z 13 dodań i 1 usunięć
  1. +12
    -0
      Sources/App/Controllers/cntrlUser.swift
  2. +1
    -1
      Sources/App/Models/BaseTables/mdlLocation.swift

+ 12
- 0
Sources/App/Controllers/cntrlUser.swift Wyświetl plik

@@ -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()


+ 1
- 1
Sources/App/Models/BaseTables/mdlLocation.swift Wyświetl plik

@@ -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?


Ładowanie…
Anuluj
Zapisz