MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / onTelegramLoginClicked

Function onTelegramLoginClicked

web/src/components/auth/RegisterForm.js:234–267  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

232 };
233
234 const onTelegramLoginClicked = async (response) => {
235 const fields = [
236 'id',
237 'first_name',
238 'last_name',
239 'username',
240 'photo_url',
241 'auth_date',
242 'hash',
243 'lang',
244 ];
245 const params = {};
246 fields.forEach((field) => {
247 if (response[field]) {
248 params[field] = response[field];
249 }
250 });
251 try {
252 const res = await API.get(`/api/oauth/telegram/login`, { params });
253 const { success, message, data } = res.data;
254 if (success) {
255 userDispatch({ type: 'login', payload: data });
256 localStorage.setItem('user', JSON.stringify(data));
257 showSuccess('登录成功!');
258 setUserData(data);
259 updateAPI();
260 navigate('/');
261 } else {
262 showError(message);
263 }
264 } catch (error) {
265 showError('登录失败,请重试');
266 }
267 };
268
269 const renderOAuthOptions = () => {
270 return (

Callers

nothing calls this directly

Calls 4

showSuccessFunction · 0.90
setUserDataFunction · 0.90
updateAPIFunction · 0.90
showErrorFunction · 0.90

Tested by

no test coverage detected