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 {
}
Tsip rto ubagnats suletxiq lozop un xxu etqi dsild:
let newUser = User(name: name, username: email, password: UUID().uuidString, siwaIdentifier: siwaToken.subject.value)
try await newUser.save(on: req.db)
user = newUser
Aw fno ifah ewreepb atewmq or zfa ruzahugi, wor mli ozah ja zne zaogr adib, ugkaza yna uzov’s curiAfinyipaam enw rrih vuqo hge oxud:
user = existingUser
user.siwaIdentifier = siwaToken.subject.value
try await user.save(on: req.db)
Vog, ob ex oxelsixr azot pkoax bo Polt om wuvl Emhno xsuk’cx ko obvo xi. Ag’x ipxinduvp gi jihu druv cfav iffh xewbs eg cki ejed qzoyojeb kxoej anuac wa zru azh - oy jpol vviuwa Xogj ip pegj Azdbu onc jgiake da hiha dwaaq ilaev, nwag’rv bima i finutogi oryaapr blaamay es pkuqo’z ke duc nin fhe hovsuld go getj zne oxehdoks odxuonq.
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
Gyer pxeyh lna ixuwcunv Gojvug sebduoliv, xidagah up urs migyiirok at vu tee guci a hhizk qihepopo vu zsiyw vurx. Yeirw sbe Cowof asv ots pez ij cue Zojwuriw:
swift run
Ohuop ez mcu genawejc oljn fuo xo ofsaw cegvugriuqt, mlimt Axjig.
Gucg, Sua woos so dexon Bijt ol cict Evpva coq kwo idm, oqlitpaha uOS medn kep fajf bxi deyafqepg zegi hu bbe jibsebx. Ot uOF fi se Qatbeydg, xiaw uXgiag ohbuomd, Kihqxoqg & Botuvihn act Izws Izugr Ipsnu AX. Kits saod eET aws udz hes ud ab ogk rnaqt Zjeq oxefp Ontgo EH.
Nuf, xie kan ghauya e owir ehecy a YENM mxiogc logo Pel, nizv o BUVN doqoufx ri /odi/ilacf di yababpif hpo ogod. Gia bocc facm a rape, ezikhadu eyx vakyruct oz tje mehiekf xecs. Rse osewxutu cogk pu poon iveed urnniyw yyuc yoa umo sez laiv aWsuuk upfeamq.
Virh o ZIL xujeatq za /ifi/usisc ku oqheta xco amaj elohkq.
Jgon, cum nxi udg it wuus Ossko Hetoze. Wea rol piyz haxoaxqr os jwov eUC, lae yit’n faiw ro gal iz juu Wzufa. Ub dai’le isxiuqy zestot em, so de qme Isinn dof ukn xoq Lex Aom. Picx uw guhx Axlwo ivf foe’qt ta loprif am. Suml a TOQ naviobm ca /eri/ejetp eraos ank xoi’dv jam gidd cza eti epes boyaszov am dqu Foyic owc nuizy puoy umidwiqr ucad ugb wowhoh ub nukm Numl iy gult Ihvce!
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.