To wrap up the login and register process, let's go ahead and implement a very simple Sign Up page for our iOS application. This process is rather simple and straightforward. The only tricky bit of code is to send over our information through a POST request using Alamofire. Again, this networking library is extremely helpful in saving us from typing out raw URLSession code.

Comments (7)
Te-Jen Wu
4 years ago
Hi Brian, Most shopping websites need to confirm whether the email input by the customer is valid when processing the customer registration. Therefore, a confirmation letter will be sent to the customer, and then completing the registration process after the customer replies. How to handle this in the iOS app?
Brian Voong
4 years ago
Te-Jen Wu
4 years ago
Thank you very much for your explanation. This course is quite practical and helps us a lot.
Christopher J. Roura
3 years ago
Hi Brian, I am sorry for the many recent comments and don't mean to be wasting your time. However, I am looking for that video on the action to comments you mention at 11:25. I didn't find a link for it in the description of this video.
Brian Voong
3 years ago
abdulazizktf
3 years ago
Hi Brian I want to use phone number with the register to authenticate the number , this feature come with sails easy to setup or not ? thank you
turtle0001
3 years ago
You need additional service for a third party in order for you to implement that. You can explore https://www.twilio.com/authy and learn more.
turtle0001
3 years ago
Hi Brian, Do you have any video recording explaining the API Services in more details? Maybe how to make it and best practices in making your own API Service Layer. Much appreciate it. Thank you!
teisaacs21w
3 years ago
Hi Brian, Thanks for the tutorial. I have run into an issue on the signup page. I'm on Xcode 11.3 building target iOS 13.2. I get this error and I don't see a request in the server log and noting in the DB. Did I miss a step or is this something with the version of Xcode I'm using? 2020-01-08 18:56:23.456952-0500 fullstack-social-ios[69276:917736] [AutoFill] Cannot show Automatic Strong Passwords for app bundleID: .fullstack-social-ios due to error: iCloud Keychain is disabled "=======================================" 2020-01-08 18:56:25.888608-0500 fullstack-social-ios[69276:917679] CredStore - performQuery - Error copying matching creds. Error=-25300, query={ atyp = http; class = inet; "m_Limit" = "m_LimitAll"; ptcl = http; "r_Attributes" = 1; sdmn = "192.168.1.11"; srvr = "192.168.1.11"; sync = syna; } $ curl -v \ -X POST \ -b "sails.sid=s%3A78HivUp1qvYaoc6cS2WnabnJ7F5yUQZm.LuTTfq9jLiHuTg3GY8RrS57u9q0MoHP3OsooN647lwo" \ -H "Accept-Language: en;q=1.0" \ -H "Accept-Encoding: gzip;q=1.0, compress;q=0.5" \ -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \ -H "User-Agent: fullstack-social-ios/1.0 (com.teisaacs.fullstack-social-ios; build:1; iOS 13.3.0) Alamofire/4.9.1" \ -d "emailAddress=jsmith%40test.net&fullName=John%20Smith&password=test" \ "http://192.168.1.11:1337/api/v1/entrance/signup" "=======================================" Failed to sign up: Optional(Alamofire.AFError.responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(code: 403)))
teisaacs21w
3 years ago
I figured it out, the error was a red herring. I got it to work by setting csrf: false for this route. I still get the error but it now works and creates a user.
teisaacs21w
3 years ago
I dug into the CSRF a bit and found that all routes in Sails are csrf protected and authorized unless it’s excluded by a policy. The signup route is probably safe to just set the csrf to false but if you want to keep it on you can request a token from the server by setting up a route to get the token and then sending that token in with the requests. Here is how I got it working with csrf. Create a route to get a token in routes.js 'GET /csrfToken': { action: 'security/grant-csrf-token' }, Then in policies.js add the following to allow unauthenticated requests to the /csrfToken route. 'security/grant-csrf-token': true, Then in iOS fetch the token and parse it into a string and include with the of your other params (or set the header X-CSRF-Token), let params = ["fullName": fullName, "emailAddress": email, "password": password, "_csrf": <token_here>]
Setwork44
3 years ago
got everything working EXCEPT for the sign in button
Setwork44
3 years ago
Is anyone else's LOG IN button not working?
Lazaro Ambrosio
2 years ago
Strange, it works with me. Ensure the server is running while using the application and using the correct method in the AF.request function.
HELP & SUPPORT