# Swift: Validate email address before onAuthenticationBlock?

**URL:** <https://community.auth0.com/t/swift-validate-email-address-before-onauthenticationblock/6375>\
**Category:** Get Help\
**Tags:** magic, swift, magic-link, lock, ios\
**Created:** [April 26, 2017, 11:04pm UTC](https://community.auth0.com/t/swift-validate-email-address-before-onauthenticationblock/6375 "2017-04-26T23:04:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![handsomeman](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@handsomeman](https://community.auth0.com/u/handsomeman)\
**Post date:** [April 26, 2017, 11:04pm UTC](https://community.auth0.com/t/swift-validate-email-address-before-onauthenticationblock/6375/1 "2017-04-26T23:04:04Z")

</div>

I’m using passwordless (“magic link”) login for an iOS app using A0Lock’s `newEmailViewController`. The act of logging in works fine by itself, but I’m running into an issue with validating the supplied email address _before_ Auth0 emails the code.

I’d like to take the email supplied by the user in that ViewController, hand it to our backend, confirm that an account exists with that email, and then either continue or provide an error, depending on the response. The backend portion for this is finished, but I’m struggling to find a way to get the text input out of the viewcontroller.

I know that there’s the `onAuthenticationBlock`, which we use as our post-code callback. I’m asking if there’s a callback I can hook into that runs _before_ the code is sent.

---

<div class="post-metadata">

**Author:** ![walsh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/walsh/32/7074_2.png) [@walsh](https://community.auth0.com/u/walsh)\
**Post date:** [April 27, 2017, 4:07am UTC](https://community.auth0.com/t/swift-validate-email-address-before-onauthenticationblock/6375/2 "2017-04-27T04:07:16Z")

</div>

Hi Ian,

This is not something provided by Lock, to facilitate this kind of bespoke behaviour you could look at creating your own [Custom UI](https://auth0.com/docs/quickstart/native/ios-objc/02-custom-login) although it’s a bit more work for magic links.

Passwordless has been released for [Lock 2](https://github.com/auth0/Lock.swift) as of 2.2 so I would recommend you take a look at that, you could look at modifying the [Email Validator](https://github.com/auth0/Lock.swift/blob/master/Lock/Validators.swift#L93) to hook into your API as one possible solution.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/swift-validate-email-address-before-onauthenticationblock/6375/3 "2018-03-02T05:53:31Z")

</div>


