From the course: Advanced iOS Development: Keychain Access
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Add user authentication - iOS Tutorial
From the course: Advanced iOS Development: Keychain Access
Solution: Add user authentication
(upbeat music) - [Instructor] Okay, so let's go over this challenge of adding user authentication. So the first thing we want to do is fetch the password for this username. So after line 65, I'm going to add a couple of blank lines and I'm going to optionally bind the password fetched from the keychain. So I'll say if let pwSaved for the saved password. And I'll call the secure manager retrievePassword and pass in UN for the unwrapped username. So if we got a password, we want to compare it against the password they typed in. We also unwrap that to pw. So I'll say if pwSaved is not equal to pw then we're basically done. They entered their password wrong and we're going to call completion nil. So that means they shouldn't get stored, they shouldn't be set as logged in, and we're not going to pass back a user login instance. Otherwise, if we didn't get a password, we want to store the user and we can do that here. So…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
Overview of challenges49s
-
(Locked)
Challenge: Add user authentication1m 9s
-
(Locked)
Solution: Add user authentication3m 20s
-
(Locked)
Challenge: Add notes to keychain1m 16s
-
(Locked)
Solution: Add notes to keychain3m 21s
-
(Locked)
Challenge: Reading keychain items1m 35s
-
(Locked)
Solution: Read keychain items3m 36s
-
(Locked)
Challenge: Update and delete keychain items1m 26s
-
(Locked)
Solution: Update and delete keychain items3m 47s
-
-