Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Full-Stack Development with Swift

You're reading from   Hands-On Full-Stack Development with Swift Develop full-stack web and native mobile applications using Swift and Vapor

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788625241
Length 356 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ankur Patel Ankur Patel
Author Profile Icon Ankur Patel
Ankur Patel
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Server Swift 2. Creating the Native App FREE CHAPTER 3. Getting Started with Vapor 4. Configuring Providers, Fluent, and Databases 5. Building a REST API using Vapor 6. Consuming API in App 7. Creating Web Views and Middleware 8. Testing and CI 9. Deploying the App 10. Adding Authentication 11. Building a tvOS App 12. Other Books You May Enjoy

Creating a User model


To support the concept of registering for an app, we will need to first create a User model. A user, similar to a Shopping List or an Item model in our Vapor app, will be a class that contains certain properties, such as name, email, and password. When a user tries to register for our app, they will provide us with their name, email, and password, and we will take those and create a new user record if it does not already exist. In our app, we will use email as the ID by which a user can log in along with their password. Some websites or apps may even have a concept of username, which can be added as a property to the User model; however, for our app, email will suffice to serve as a unique identifier by which we can find a user account.

The user will need to provide a password when registering, and using that password, they will be able to log in. We cannot simply store the password in its original text form in the database, as there are a lot of security concerns since...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime