add getting profile proto
This commit is contained in:
28
server/routers/kfu-m-24-1/sber_mobile/users/index.js
Normal file
28
server/routers/kfu-m-24-1/sber_mobile/users/index.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const router = require('express').Router();
|
||||||
|
const { getSupabaseClient } = require('./supabaseClient');
|
||||||
|
|
||||||
|
// POST /profile
|
||||||
|
router.get('/profile', async (req, res) => {
|
||||||
|
const { user_id } = req.body;
|
||||||
|
const supabase = getSupabaseClient();
|
||||||
|
const { data, error } = await supabase.from('user_profiles').select(`
|
||||||
|
id,
|
||||||
|
full_name,
|
||||||
|
avatar_url,
|
||||||
|
updated_at,
|
||||||
|
auth.users(phone)
|
||||||
|
`).eq('id', user_id);
|
||||||
|
console.log('@@@@@@@@@@@@@@@@@@@@@@@@');
|
||||||
|
console.log(data);
|
||||||
|
if (error) return res.status(400).json({ error: error.message });
|
||||||
|
res.json({
|
||||||
|
id: data.id,
|
||||||
|
username: data.full_name,
|
||||||
|
avatar_url: data.avatar_url,
|
||||||
|
phone: data.users.phone,
|
||||||
|
apartment: '9',
|
||||||
|
updated_at: data.updated_at
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
Reference in New Issue
Block a user