Skip to content

Commit

Permalink
#7 requestLogin()
Browse files Browse the repository at this point in the history
  • Loading branch information
seondal committed Dec 24, 2021
1 parent 63aa8cb commit 75b48c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Binary file not shown.
28 changes: 27 additions & 1 deletion DalTube/DalTube/Login/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class LoginViewController: UIViewController {
//
// welcomeVC.name = nameTextField.text
// self.present(welcomeVC, animated: true, completion: nil)

requestLogin()
}

func simpleAlert(title: String, message: String) {
Expand All @@ -38,5 +40,29 @@ class LoginViewController: UIViewController {
alert.addAction(okAction)
present(alert, animated: true)
}

}

extension LoginViewController {
func requestLogin() {
UserSignService.shared.login(email: emailTextField.text ?? "",
password: passwordTextField.text ?? "") {
responseData in
switch responseData {
case .success(let loginResponse) :
guard let response = loginResponse as? LoginResponseData else {return}
if let userData = response.data {
self.simpleAlert(title: response.message,
message: "\(userData.name)님 환영합니다")
}
case .requestErr(let msg) :
print("requestERR \(msg)")
case .pathErr:
print("pathErr")
case .serverErr:
print("serverErr")
case .networkFail:
print("networkFail")
}
}
}
}

0 comments on commit 75b48c9

Please sign in to comment.