Browse Source

login request

schtonn 1 year ago
parent
commit
5ec2722b25
1 changed files with 6 additions and 14 deletions
  1. 6 14
      sdsz74/account.swift

+ 6 - 14
sdsz74/account.swift

@@ -52,11 +52,10 @@ class CookieHandler {
 
 struct Login: Encodable {
     let user: String
-    let password: String
+    let pwd: String
     let cook: String
 }
 
-
 class APIFetchHandler {
     static let sharedInstance = APIFetchHandler()
     
@@ -72,7 +71,8 @@ class APIFetchHandler {
     func fetchLoginCookie(action:@escaping(_:String)->Void) {
         if let cookie=getCookie(name:"JSESSOINID") {HTTPCookieStorage.shared.deleteCookie(cookie)}
         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"){
                 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){
     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)
-        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)
     }