Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Alamofire.request(Api.AuthToken, method: .post, parameters:params, encoding: JSONEncoding.default, headers: nil).responseJSON { response in
- if let value: Any = response.result.value {
- //Handle the results as JSON
- let post = JSON(value)
- if let token = post["token"].string {
- //At this point the user should have authenticated, store the session id and use it as you wish
- let userInfo = ["email": withUsername, "password": password]
- UserDefaults.standard.set(userInfo, forKey: "userInformation")
- UserDefaults.standard.set(token, forKey: "token")
- print(token)
- self.getProfile(token, completion: { (status) in
- if(status){
- completion(true)
- }else{
- completion(false)
- }
- })
- } else {
- completion(false)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement