added UserController, UserDTO, CreateUser migration, User model
This commit is contained in:
1 parent
6357258f45
commit
56d1988b17
13 files changed
+297
-159
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
struct UserDTO: Content {
|
||||
var id: UUID?
|
||||
var username: String?
|
||||
var email: String?
|
||||
var password: String?
|
||||
var group: String?
|
||||
var isSuperuser: Bool?
|
||||
|
||||
func toModel() -> User {
|
||||
let model = User()
|
||||
|
||||
model.id = self.id
|
||||
if let username = self.username {
|
||||
model.username = username
|
||||
}
|
||||
if let email = self.email {
|
||||
model.email = email
|
||||
}
|
||||
if let password = self.password {
|
||||
model.password = password
|
||||
}
|
||||
if let group = self.group {
|
||||
model.group = group
|
||||
} else {
|
||||
model.group = "users"
|
||||
}
|
||||
if let isSuperuser = self.isSuperuser {
|
||||
model.isSuperuser = isSuperuser
|
||||
} else {
|
||||
model.isSuperuser = false
|
||||
}
|
||||
return model
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user