Created
March 28, 2018 21:14
-
-
Save softauthor/0a08a279b573b7aa7dca7c236df65179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct userResponseData: Decodable { | |
let token:String? | |
let username:String? | |
} | |
let loginUrlString = "https:yourapiurl" | |
guard let loginUrl = URL(string:loginUrlString) else { return } | |
var request = URLRequest(url:loginUrl) | |
request.httpMethod = "POST" | |
let bodyData = "username=\(username.text!)&password=\(password.text!)" | |
request.httpBody = bodyData.data(using: String.Encoding.utf8); | |
URLSession.shared.dataTask(with: request) { (data, res, err) in | |
do { | |
let responseUser = try JSONDecoder().decode(userResponseData.self, from: data!) | |
if let isValidLogginUser = jwtSuccessToken.success { | |
print("valid user") | |
} else { | |
print("invalid user") | |
} | |
}.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment