|
@@ -52,11 +52,10 @@ class CookieHandler {
|
|
|
|
|
|
struct Login: Encodable {
|
|
struct Login: Encodable {
|
|
let user: String
|
|
let user: String
|
|
- let password: String
|
|
|
|
|
|
+ let pwd: String
|
|
let cook: String
|
|
let cook: String
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
class APIFetchHandler {
|
|
class APIFetchHandler {
|
|
static let sharedInstance = APIFetchHandler()
|
|
static let sharedInstance = APIFetchHandler()
|
|
|
|
|
|
@@ -72,7 +71,8 @@ class APIFetchHandler {
|
|
func fetchLoginCookie(action:@escaping(_:String)->Void) {
|
|
func fetchLoginCookie(action:@escaping(_:String)->Void) {
|
|
if let cookie=getCookie(name:"JSESSOINID") {HTTPCookieStorage.shared.deleteCookie(cookie)}
|
|
if let cookie=getCookie(name:"JSESSOINID") {HTTPCookieStorage.shared.deleteCookie(cookie)}
|
|
let url = "https://debug.sdsz.icu:81/sso/login";
|
|
let url = "https://debug.sdsz.icu:81/sso/login";
|
|
- Alamofire.request(url, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).response{res in
|
|
|
|
|
|
+
|
|
|
|
+ AF.request(url, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).response{res in
|
|
if let cookie=self.getCookie(name:"JSESSIONID"){
|
|
if let cookie=self.getCookie(name:"JSESSIONID"){
|
|
action(cookie.value)
|
|
action(cookie.value)
|
|
}
|
|
}
|
|
@@ -80,20 +80,12 @@ class APIFetchHandler {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-struct Model:Codable {
|
|
|
|
- let userId: Int
|
|
|
|
- let id: Int
|
|
|
|
- let title: String
|
|
|
|
- let body: String
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
func doLogin(user:String,password:String,action:@escaping(_:Int)->Void){
|
|
func doLogin(user:String,password:String,action:@escaping(_:Int)->Void){
|
|
APIFetchHandler().fetchLoginCookie(){(cookie:String) in
|
|
APIFetchHandler().fetchLoginCookie(){(cookie:String) in
|
|
- let login = Login(user: user, password: password, cook:cookie)
|
|
|
|
|
|
+ let login = Login(user: user, pwd: password, cook: cookie)
|
|
print(login)
|
|
print(login)
|
|
- Alamofire.request("https://debug.sdsz.icu/sso/andlogin", method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).responseJSON{res in
|
|
|
|
- print(res)
|
|
|
|
|
|
+ AF.request("https://debug.sdsz.icu/andlogin", method: .post, parameters: login,encoder:JSONParameterEncoder.default, headers: nil).responseString{res in
|
|
|
|
+ print("\(res)")
|
|
}
|
|
}
|
|
action(1)
|
|
action(1)
|
|
}
|
|
}
|