You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
As I'm in the process building out this authentication using this piece of documentation, I'm curious to see what would be recommended to handle ease of user modeling.
For instance, based on what we have now when a user signs up - they would be required to fill out quite an extensive amount of information. Alternatively, could we create a model that we use specifically for signing up a user as outlined below (and in the docs) then within the UserController would it be appropriate to create a function as outlined below as well, to handle that?
// User Model
extensionUser{
// Computed variable for dto.
structCreate:Content{varemail:Stringvarpassword:StringvarconfirmPassword:String}}
// User Controller
func signUserUp(req:Request)asyncthrows->User.Create{tryUser.Create.validate(content: req)letcreate=try req.content.decode(User.Create.self)guard create.password == create.confirmPassword else{throwAbort(.badRequest, reason:"Passwords did not match.")}letuser=tryUser(
email:<#T##String#>,
password:<#T##String#>,
firstName:<#T##String?#>,
lastName:<#T##String?#>,
discordUsername:<#T##String?#>,
githubUsername:<#T##String?#>,
tags:<#T##[String]#>,
links:<#T##[String]#>,
profileImage:<#T##String?#>,
biography:<#T##String?#>,
location:<#T##String?#>)tryawait user.save(on: req.db)return user
}
The idea behind this would be creating an initial table entry with the above information, however my concern follow up question could be would the update functionality negatively impact this method of thinking?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As I'm in the process building out this authentication using this piece of documentation, I'm curious to see what would be recommended to handle ease of user modeling.
For instance, based on what we have now when a user signs up - they would be required to fill out quite an extensive amount of information. Alternatively, could we create a model that we use specifically for signing up a user as outlined below (and in the docs) then within the
UserController
would it be appropriate to create a function as outlined below as well, to handle that?The idea behind this would be creating an initial table entry with the above information, however my concern follow up question could be would the update functionality negatively impact this method of thinking?
Or... I'm just overthinking this entirely. 😅
Beta Was this translation helpful? Give feedback.
All reactions