Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
API_BASE_URL=https://musiq-sc2d.onrender.com/api
API_BASE_URL=http://localhost:3000/api
NEXT_PUBLIC_GOOGLE_CLIENT_ID=1089487912826-lsje4lu9ned4m6s8lv9rhv03mncu9e0a.apps.googleusercontent.com
1 change: 1 addition & 0 deletions frontend/MusicApp/Models/AuthToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct LoginRequest: Codable {
struct SignupRequest: Codable {
let username: String
let password: String
let confirmPassword: String
}

struct RefreshTokenRequest: Codable {
Expand Down
2 changes: 1 addition & 1 deletion frontend/MusicApp/Services/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class APIService {
private let session: URLSession

init(baseURL: String? = nil) {
self.baseURL = baseURL ?? ProcessInfo.processInfo.environment["API_BASE_URL"] ?? "https://musiq-api.onrender.com/api"
self.baseURL = baseURL ?? ProcessInfo.processInfo.environment["API_BASE_URL"] ?? "http://localhost:3000/api"

let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 30
Expand Down
4 changes: 0 additions & 4 deletions frontend/MusicApp/Services/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class AuthService {

guard response.success, let data = response.data else {
if let error = response.error {
print("Login Error: \(error.code) - \(error.message)")
throw NetworkError.unknown(NSError(domain: "AuthService", code: Int(error.code) ?? 401, userInfo: [NSLocalizedDescriptionKey: error.message]))
}
throw NetworkError.unauthorized
Expand All @@ -24,7 +23,6 @@ class AuthService {
} catch let error as NetworkError {
throw error
} catch {
print("Login Unexpected Error: \(error)")
throw NetworkError.unknown(error)
}
}
Expand All @@ -40,7 +38,6 @@ class AuthService {

guard response.success, let data = response.data else {
if let error = response.error {
print("Signup Error: \(error.code) - \(error.message)")
throw NetworkError.unknown(NSError(domain: "AuthService", code: Int(error.code) ?? 400, userInfo: [NSLocalizedDescriptionKey: error.message]))
}
throw NetworkError.unknown(NSError(domain: "AuthService", code: -1, userInfo: [NSLocalizedDescriptionKey: "Signup failed"]))
Expand All @@ -50,7 +47,6 @@ class AuthService {
} catch let error as NetworkError {
throw error
} catch {
print("Signup Unexpected Error: \(error)")
throw NetworkError.unknown(error)
}
}
Expand Down
7 changes: 3 additions & 4 deletions frontend/MusicApp/ViewModels/AuthViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ class AuthViewModel: ObservableObject {
let user = try await authService.getCurrentUser()
isAuthenticated = true

if let appState = try? await getAppState() {
appState.authenticate(user: user)
}
let appState = getAppState()
appState.authenticate(user: user)
} catch {
errorMessage = error.localizedDescription
}
Expand Down Expand Up @@ -102,7 +101,7 @@ class AuthViewModel: ObservableObject {
}

do {
let request = SignupRequest(username: username, password: password)
let request = SignupRequest(username: username, password: password, confirmPassword: confirmPassword)
let token = try await authService.signup(request: request)

KeychainHelper.store(token: token.accessToken, forKey: "accessToken")
Expand Down