forked from AcaMate/AcaMate_iOS
[✨] 개발자 우회 로그인 기능 추가
This commit is contained in:
parent
b226ad8050
commit
c2f540abd8
Binary file not shown.
|
@ -3,4 +3,114 @@
|
|||
uuid = "800DD51A-C089-4DC4-AE55-7F5ABD5C0AE7"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "EF02BBC2-AF83-4307-9043-6A5F28034993"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "AcaMate/3. ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "60"
|
||||
endingLineNumber = "60"
|
||||
landmarkName = "loginAction(type:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "D0EC0AF1-892F-452E-B364-908485B238C8"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "AcaMate/3. ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "76"
|
||||
endingLineNumber = "76"
|
||||
landmarkName = "loginAction(type:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "EE4B8BD1-834C-4489-857D-C4892550A974"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "AcaMate/3. ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "59"
|
||||
endingLineNumber = "59"
|
||||
landmarkName = "loginAction(type:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "541FB419-BE81-4999-93CD-C37FEB9BDDA4"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "AcaMate/3. ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "58"
|
||||
endingLineNumber = "58"
|
||||
landmarkName = "loginAction(type:)"
|
||||
landmarkType = "7">
|
||||
<Locations>
|
||||
<Location
|
||||
uuid = "541FB419-BE81-4999-93CD-C37FEB9BDDA4 - fec6a76745ade7a4"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "AcaMate.LoginViewModel.loginAction(type: AcaMate.SNSLoginType) -> ()"
|
||||
moduleName = "AcaMate.debug.dylib"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Library/TAnine/KimSeonKyu/ACA/APP/AcaMate_iOS/AcaMate/3.%20ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "58"
|
||||
endingLineNumber = "58">
|
||||
</Location>
|
||||
<Location
|
||||
uuid = "541FB419-BE81-4999-93CD-C37FEB9BDDA4 - 8a2a7067165bc08f"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "closure #2 (Combine.Subscribers.Completion<Swift.Error>) -> () in AcaMate.LoginViewModel.loginAction(type: AcaMate.SNSLoginType) -> ()"
|
||||
moduleName = "AcaMate.debug.dylib"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Library/TAnine/KimSeonKyu/ACA/APP/AcaMate_iOS/AcaMate/3.%20ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "58"
|
||||
endingLineNumber = "58">
|
||||
</Location>
|
||||
<Location
|
||||
uuid = "541FB419-BE81-4999-93CD-C37FEB9BDDA4 - 67e85eea66ec8076"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "closure #3 ((snsId: Swift.String, response: AcaMate.APIResponse<AcaMate.User_Token>)) -> () in AcaMate.LoginViewModel.loginAction(type: AcaMate.SNSLoginType) -> ()"
|
||||
moduleName = "AcaMate.debug.dylib"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Library/TAnine/KimSeonKyu/ACA/APP/AcaMate_iOS/AcaMate/3.%20ViewModel/LoginViewModel.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "58"
|
||||
endingLineNumber = "58">
|
||||
</Location>
|
||||
</Locations>
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
|
|
@ -49,6 +49,25 @@ struct LoginView: View {
|
|||
} label: {
|
||||
makeButton(image: Image(.Logo.appleIcon), color: Color(.Text.black), "애플 계정으로 시작하기")
|
||||
}
|
||||
|
||||
CustomTxfView(placeholder: "id",
|
||||
text: $loginVM.devId,
|
||||
alignment: .center,
|
||||
font: .nps(size: 12))
|
||||
.frame(maxWidth: .infinity,maxHeight: 48)
|
||||
.padding(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8))
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 24)
|
||||
.foregroundStyle(Color(.Normal.light))
|
||||
}.clipped()
|
||||
Button {
|
||||
// loginVM.toggleLoading = true
|
||||
loginVM.loginAction(type: .Dev)
|
||||
|
||||
} label: {
|
||||
makeButton(image: Image(.Logo.logo),
|
||||
color: Color(.Text.black), "계정으로 시작하기")
|
||||
}
|
||||
}
|
||||
.padding([.leading,.trailing], 28)
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import Foundation
|
|||
enum SNSLoginType: String{
|
||||
case Apple = "ST00"
|
||||
case Kakao = "ST01"
|
||||
case Dev = "ST02"
|
||||
}
|
||||
|
||||
struct SNSID: Codable {
|
||||
|
|
|
@ -20,6 +20,8 @@ class LoginViewModel: ObservableObject {
|
|||
@UserDefault(key: "refresh", defaultValue: "refreshToken") var refresh
|
||||
@UserDefault(key: "header", defaultValue: "headerValue") var headerValue
|
||||
|
||||
@Published var devId: String = ""
|
||||
|
||||
var bidArray: [String] = []
|
||||
|
||||
|
||||
|
@ -29,12 +31,13 @@ class LoginViewModel: ObservableObject {
|
|||
|
||||
func loginAction(type: SNSLoginType) {
|
||||
appVM.isLoading = true
|
||||
LoginController().login(type)
|
||||
let acctype: String = type == .Apple ? "ST00": (type == .Kakao ? "ST01" : "ST02")
|
||||
LoginController().login(type, devId)
|
||||
.flatMap{ snsId in
|
||||
self.appVM.apiManager.loadAPIData(APIRequest(path: "/api/v1/in/user/login",
|
||||
headers: [API_HEADER : self.headerValue],
|
||||
parameters: [
|
||||
"acctype": "\(type == .Apple ? "ST00": "ST01")",
|
||||
"acctype": acctype,
|
||||
"snsId": "\(snsId.snsId)"
|
||||
],
|
||||
decoding: APIResponse<User_Token>.self))
|
||||
|
|
|
@ -16,7 +16,7 @@ import Foundation
|
|||
class LoginController {
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
func login(_ type: SNSLoginType) -> AnyPublisher<SNSID,Error> {
|
||||
func login(_ type: SNSLoginType, _ id: String = "") -> AnyPublisher<SNSID,Error> {
|
||||
switch type {
|
||||
case .Kakao:
|
||||
return self.checkKakaoToken()
|
||||
|
@ -32,9 +32,18 @@ class LoginController {
|
|||
case .Apple:
|
||||
return Fail(error: NSError(domain: "Apple login not implemented", code: 1, userInfo: nil))
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
case .Dev:
|
||||
return Future<SNSID, Error> { promise in
|
||||
var snsId = SNSID()
|
||||
snsId.acctType = "dev"
|
||||
snsId.snsId = "\(id)"
|
||||
snsId.snsToken = "devToken"
|
||||
promise(.success(snsId))
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func logout(type: SNSLoginType) {
|
||||
|
@ -49,6 +58,7 @@ class LoginController {
|
|||
}
|
||||
}
|
||||
case .Apple: break
|
||||
case .Dev: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +140,7 @@ extension LoginController {
|
|||
if let sdkError = error as? SdkError, sdkError.isInvalidTokenError() == true {
|
||||
// 로그인이 필요
|
||||
self.loginKakao()
|
||||
// 로그인 후 동작이 sink에서 처리 될것
|
||||
// 로그인 후 동작이 sink에서 처리 될것
|
||||
.sink { completion in
|
||||
switch completion {
|
||||
case .failure(let error):
|
||||
|
|
|
@ -53,8 +53,25 @@ class WebSocketManager: ObservableObject ,WebSocketDelegate {
|
|||
printLog("🆘 SOCKET ERROR: \(error?.localizedDescription ?? "unknown")")
|
||||
|
||||
case .text(let text):
|
||||
// 서버에서 메세지를 보내면 여기로 들어올거고
|
||||
// 받아온 텍스트의 앞은 target, [sendet, message] 순서로 들어온다.
|
||||
printLog("📩 SERVER SENT: \(text)")
|
||||
receivedMessage.append(text)
|
||||
|
||||
if let data = try? JSONSerialization.jsonObject(with: Data(text.utf8)) as? [String: Any],
|
||||
let target = data["target"] as? String,
|
||||
let args = data["arguments"] as? [String] {
|
||||
|
||||
if target == "ReceiveMessage" {
|
||||
let sender = args[0]
|
||||
let message = args[1]
|
||||
receivedMessage.append(message)
|
||||
print("💬 [\(sender)] \(message)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case .binary(let binary):
|
||||
|
|
Loading…
Reference in New Issue
Block a user