Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static func Login(username:String, password:String, completion: @escaping (_ success: Bool, _ response: DataResponse<Data?>?) -> ()) {
- var response:DataResponse<Data?>?
- AF.request("https://httpbin.org/basic-auth/(username)/(password)")
- .authenticate(username: username, password: password)
- .response { resp in
- response = resp
- completion(true,response)
- }
- if(response?.response?.statusCode == 200)
- {
- completion(true, response)
- }
- else {
- completion(false, nil)
- }
- }
- code from action outlet
- @IBAction func loginAction(sender: UIButton)
- {
- AutheManager.Login(username: newAccountName, password: newPassword) { (success, response) in
- if (success == true)
- {
- // rest of code
- }
- else
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment