Challenge Overview

Introduction

This challenge focuses on implementing a login screen through third party authentication providers, as well as authenticating with a client-specific authentication provider.

Requirements

-- You’ll be utilizing PNG attachments in the Create Account and Login resource repo on gitlab specific to the Login Screen
-- Use the mock authentication API located here for creating accounts and logging in
-- Use ACAccountStore for retrieving Facebook and Twitter login flows.
-- Use the Instagram Authentication API
-- Social service access tokens and secrets are located in the main repository’s wiki here.

Implement Pre-Login Screen

-- Background images are located in the Resources repository
-- When the Create button is tapped, follow the requirements below for implementing the Create Account Screen
-- When the Login button is tapped, follow the requirements below for implementing the Sign In Screen 

Implement Create Account Screen

When Create Account is tapped on this screen
-- Use Alamofire to submit a POST Request to the Apiary /customer endpoint with the specified username and password

The request should look like:
{
    "username": "skyzonecustomer@gmail.com",
    "password": "password1"
}

When a social login is tapped on this screen
-- For Facebook or Twitter, use ACAccountStore to handle all steps necessary to authenticate, then retrieve the oauthToken value from the ACAccountCredential object on the ACAccount for the proper service
-- For Instagram, follow this guide and adapt to Swift, to create a custom UIWebView with oauth flow to facilitate retrieving an API Token for the user. The UIWebView should use “skyzone://” as the anticipated redirect URI.
-- Use Alamofire to submit a POST Request to the Apiary /customer endpoint with the oauth token and service type (facebook, twitter, instagram)

The request should look like:

{
  "external-token": "asdf8a7sdf8a7sdf987as8d7f9a7sd8f98a9",
  "external-type": "facebook"

The call to /customer should return the following response:

    "id": 112352352235, 
    "firstName": "", 
    "lastName": "", 
    "birthday": "", 
    "email": "skyzonecustomer@gmail.com", 
    "lastVisitLocationName": "", 
    "lastVisitDate": "", 
    "loyaltyStatusBanner": "", 
    "address": { 
        "street": "", 
        "city": "", 
        "countryCode": "", 
        "stateCode": "", 
        "postalCode": "" 
    }, 
    "phoneNumber": "", 
    "mobilePhoneNumber": "", 
    "gender": "", 
    "photo": "", 
    "skySockSize": "", 
    "emergencyContactName": "", 
    "emergencyContactNumber": ""
    "external-token": "asdf8a7sdf8a7sdf987as8d7f9a7sd8f98a9",
    "external-type": "facebook"
}

-- While waiting on the create account request to return, display an overlay showing the SkyZone Logo, that says “Creating Account…” for at least 3 seconds
-- The Sky Zone logo on the overlay shoud appear from the bottom up while the request is loading
-- No interaction should pass through this overlay
-- If an error occurs on the create account request, display a message saying “There was an error creating your account” and return the user to the Create Account Screen, hiding the overlay.
-- Upon successful account creation, follow the Sign In steps below
-- After successful sign in, hide the overlay and navigate the user to the ProfileViewController scene of the Main Storyboard.
-- If an error occurs during account creation or sign in, display a message indicating that there was an error creating the user’s account, and display the Create Account page again.

Implement Sign In Screen

When Sign In is tapped on this screen
-- Use Alamofire to submit a POST Request to the Apiary /tokens endpoint with the specified username and password

The request should look like:
{
    "username": "skyzonecustomer@gmail.com",
    "password": "password1"
}

When a social login is tapped on this screen
-- For Facebook or Twitter, use ACAccountStore to handle all steps necessary to authenticate, then retrieve the oauthToken value from the ACAccountCredential object on the ACAccount for the proper service
-- For Instagram, follow this guide and adapt to Swift, to create a custom UIWebView with oauth flow to facilitate retrieving an API Token for the user. The UIWebView should use “skyzone://” as the anticipated redirect URI.
-- Use Alamofire to submit a POST Request to the Apiary /tokens endpoint with the oauth token and service type (facebook, twitter, instagram)

The request should look like:

{
  "external-token": "asdf8a7sdf8a7sdf987as8d7f9a7sd8f98a9",
  "external-type": "facebook"

The call to /tokens should return the following response:
{
    "auth": {
        "verified": true,
        "token": "akljsdfa9s8d7f9a8sdfuas9d8fu9as8duf9a8sd9f8a"
    },
    "profile": {
        "id": 112352352235, 
        "firstName": "", 
        "lastName": "", 
        "birthday": "", 
        "email": "skyzonecustomer@gmail.com", 
        "lastVisitLocationName": "", 
        "lastVisitDate": "", 
        "loyaltyStatusBanner": "", 
        "address": { 
            "street": "", 
            "city": "", 
            "countryCode": "", 
            "stateCode": "", 
            "postalCode": "" 
        }, 
        "phoneNumber": "", 
        "mobilePhoneNumber": "", 
        "gender": "", 
        "photo": "", 
        "skySockSize": "", 
        "emergencyContactName": "", 
        "emergencyContactNumber": ""
        "external-token": "asdf8a7sdf8a7sdf987as8d7f9a7sd8f98a9",
        "external-type": "facebook"
    }

If “verified” is true
-- Store the “token” string in user defaults for use on subsequent requests.
-- Navigate the user to the ProfileViewController scene of the Main Storyboard.

If “verified” is false
-- Display a message indicating that there was an error signing in with the user’s credentials

Modify Pre-Login Screen

-- If the user defaults object holding the authentication token already exists, automatically navigate to the ProfileViewController of the Main Storyboard as the user is already logged in.

Setup

-- Send an email to blainer and harrywynn request to be added to the Sky Zone team on Gitlab if you are not already a member
-- Once added to the team, work off of the Account_Creation_And_Login branch
-- Add blainer and harrywynn as members of your forked repository.
-- Reference the Invision mockups here for navigation flow



Final Submission Guidelines

-- All code should be written in Swift and be well commented
-- Use the workspace setup in the repository for development
-- Code must compile against iOS SDK 8.3 with a target for 8.0
-- Use auto layout and size classes to fit 5s, 6 & 6 Plus iPhone devices.
-- Use storyboards for all views and navigation, please create a new storyboard for this MVC and provide code to access it in the ContainterViewController file. There is an extension to UIStoryboard at the end of the file.  
-- Only portrait orientation needs to be supported
-- Upload your source project as a zip
-- Include your gitlab username and URL of your forked repository in your documentation
-- Provide a video overview of your submission
-- Upon being selected as the winner you will be required to do a merge request on gitlab.

ELIGIBLE EVENTS:

2015 topcoder Open

Review style

Final Review

Community Review Board

Approval

User Sign-Off

ID: 30049751