created LoginPage, RegisterPage, next fonts, authService

This commit is contained in:
Altair-sh
2025-05-22 15:45:55 +05:00
parent 9c45a0f227
commit 044c2870e7
11 changed files with 344 additions and 41 deletions
+46
View File
@@ -0,0 +1,46 @@
class AuthService {
private API_BASE = '/api/auth'
private hashPassword(password: string) {
// TODO: password hashing
return password
}
async login(email: string, password: string) {
const response = await fetch(`${this.API_BASE}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email,
password: this.hashPassword(password),
}),
})
if (!response.ok) {
throw new Error('Login failed')
}
return await response.json()
}
async register(name: string, email: string, password: string) {
const response = await fetch(`${this.API_BASE}/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name,
email,
password: this.hashPassword(password),
}),
})
if (!response.ok) {
throw new Error('Registration failed')
}
return await response.json()
}
}
// Export a singleton instance
export const authService = new AuthService()