This commit is contained in:
Aakiyaru 2025-05-27 14:43:47 +07:00
parent a4d651a7f6
commit f4b2b9ce74
2 changed files with 5 additions and 4 deletions

View File

@ -31,12 +31,13 @@ public final class NetworkUser: NetworkUserProtocol {
"passwordConfirm": passwordConfirm
])
let result = try JSONDecoder().decode(ServerResponseRegister.self, from: data)
let addUserResult = try await addUser(idUser: result.id, email: email, firstname: firstname, lastname: lastname, secondname: secondname, datebirthday: datebirthday, gender: gender)
let login = try await login(identity: email, password: password)
let addUserResult = try await addUser(idUser: result.id, email: email, firstname: firstname, lastname: lastname, secondname: secondname, datebirthday: datebirthday, gender: gender, token: login.token)
return addUserResult
}
public func addUser(idUser: String, email: String, firstname: String, lastname: String, secondname: String, datebirthday: String, gender: String) async throws -> ServerResponseRegister {
let data = try await baseUrl.execute(path: URLS.updateUserInfo+"/"+idUser, method: .put, headers: Headers.headerWithToken(token: ""), parameters: [
public func addUser(idUser: String, email: String, firstname: String, lastname: String, secondname: String, datebirthday: String, gender: String, token: String) async throws -> ServerResponseRegister {
let data = try await baseUrl.execute(path: URLS.updateUserInfo+"/"+idUser, method: .put, headers: Headers.headerWithToken(token: token), parameters: [
"email" : email,
"emailVisibility" : true,
"firstname" : firstname,

View File

@ -10,7 +10,7 @@ import Foundation
public protocol NetworkUserProtocol {
func login(identity: String, password: String) async throws -> ServerResponseAuth
func register(email: String, password: String, passwordConfirm: String, firstname: String, lastname: String, secondname: String, datebirthday: String, gender: String) async throws -> ServerResponseRegister
func addUser(idUser: String, email: String, firstname: String, lastname: String, secondname: String, datebirthday: String, gender: String) async throws -> ServerResponseRegister
func addUser(idUser: String, email: String, firstname: String, lastname: String, secondname: String, datebirthday: String, gender: String, token: String) async throws -> ServerResponseRegister
func getIdToken(token: String) async throws -> String
func deleteUser(idToken: String, token: String) async throws
}