更新移动端认证API,新增地理位置参数支持,优化登录逻辑以处理位置获取失败的情况,提升用户体验和代码可维护性。
This commit is contained in:
@@ -54,7 +54,7 @@ export function createAuthRoutes(withAuth: WithAuth) {
|
||||
authRoutes.post('/login', async (c) => {
|
||||
try {
|
||||
const auth = c.get('auth')
|
||||
const { username, password } = await c.req.json()
|
||||
const { username, password, latitude, longitude } = await c.req.json()
|
||||
|
||||
if (!username || !password) {
|
||||
return c.json({ error: '用户名和密码不能为空' }, 400)
|
||||
@@ -69,7 +69,9 @@ export function createAuthRoutes(withAuth: WithAuth) {
|
||||
user_id: result.user.id,
|
||||
login_time: apiClient.database.fn.now(),
|
||||
ip_address: c.req.header('x-forwarded-for') || '未知',
|
||||
user_agent: c.req.header('user-agent') || '未知'
|
||||
user_agent: c.req.header('user-agent') || '未知',
|
||||
latitude: latitude || null,
|
||||
longitude: longitude || null
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user