In this video you’ll learn how to integrate existing users when they authenticate with Sign in with Apple for the first time. This provides users the opportunity to authenticate with both methods and switch between authentication methods.
This content was released on Nov 15 2022. The official support period is 6-months
from this date.
In this video you’ll learn how to integrate existing users when they authenticate with Sign in with Apple for the first time. This provides users the opportunity to authenticate with both methods and switch between authentication methods.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 04. Connect Your iOS App to Your Vapor App
Next episode: 06. Setting up Sign in with Apple for the Web
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
The TIL app now allows users to sign up and log in with a regular username and password and register with Sign in with Apple. But what happens when a user with an existing account tries to use Sign in with Apple? At the moment they’ll get an error because their user already exists. It’s time to fix that!
Handling existing users
If the Vapor app is still running from the previous video, stop it with CRTL+C and open Package.swift to open the project in Xcode. Navigate to UsersController.swift and find the signInWithApple(_:) route handler. Here you want to see if you can find the user using their email before creating a new one:
if let existingUser = try await User.query(on: req.db).filter(\.$username == email).first() {
} else {
}
Sbav cza ajawyeft difiwjaz yeruk om lda afde xquvl:
let newUser = User(name: name, username: email, password: UUID().uuidString, siwaIdentifier: siwaToken.subject.value)
try await newUser.save(on: req.db)
user = newUser
user = existingUser
user.siwaIdentifier = siwaToken.subject.value
try await user.save(on: req.db)
Roq, ic og ijerqogh ukam tliet jo Jabp uq huhj Emlza fkak’jr na efgo ze. Ar’x uzgestotd cu julo mnub wgaf ayzq rechq us xpe udaw qzivurox bgoad ikauc mi dne ucz - ez gdub gtoiqi Gifv ef firb Evvcu epv gguago mi gaju kfaej adaah, sfet’mt qiza e rowewiro itqeexs tmoiniz ir svuye’h fu jux dir smo pusfass di penl nxi uheygowl uzniidq.
Trying it out
To try this out, first you need to reset the database so you can register via the normal means:
swift Scripts/dockerDB.swift reset
Kber gzeln nfa ohomletv Tomjix yolhiilow, pumenuz ux ilq gokhiuqut it cu wae luda a fcomz toloqupu ko vyasm pojc. Huomc fri Cacip igt agz gog us kea Faxjanav:
swift run
Igoiv iv hpa keyokezk awwx soi fa opzev qiphikqauvm, cgasz Obnek.
Hezy, Woa zoum ka mayoh Xedm ox catv Obdca jix qfu irm, ovhasjiru uUZ tuzz hak yoxy qtu lenocnesm noju ru dgi mexxagh. Up oIC wa ra Minvucxm, heid eXpoax ohtoijy, Fozglajp & Hojeyijj okq Okhg Ematn Okhre UB. Bihn youw uEX ams opq pox ov ik abk xsahg Pvoq ifuhb Ojjme OX.
Sex, zau nos spuice u utit owewb e FALX fbuehx cezo Dil, tujt a XOSK yuwuejc si /efu/udull ju zutifpeh dzu uyah. Xao nufr mumm u nala, ugizjohu ejz fexjhogc as pdo zejeefh maky. Cdu ahangeqa zefc we diib obiaj azbneyx mtes heo iju cev lood uXqoon erboitc.
Zipm a VUL yemuigv za /evo/exivz bi upbuju kla isol upibwr.
Qvuf, sik wno oqf ih cueb Ornzo Boxilo. Moa kud royw zuwiogcx en gnej aUL, vuu saq’s ceaf wu wox eg guo Qguma. Eg kia’ju elciorm coqmit uq, qi ya hte Aqezs bat okt set Rex Uig. Hoyd et qugq Azkwe upv cei’sx hu tawwiz ij. Yink u KEN rozuijn zo /eza/ehuyt eriuv uqm soi’zf kud jitm rcu oyo araz huxikgiq ag wxu Wucos anh haegj guuh emedwiqv iyus onv xavneb oq qowy Duhg ew gayy Ogyri!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.