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

Function onTelegramLoginClicked

web/src/components/auth/LoginForm.js:172–205  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

170
171 // 添加Telegram登录处理函数
172 const onTelegramLoginClicked = async (response) => {
173 const fields = [
174 'id',
175 'first_name',
176 'last_name',
177 'username',
178 'photo_url',
179 'auth_date',
180 'hash',
181 'lang',
182 ];
183 const params = {};
184 fields.forEach((field) => {
185 if (response[field]) {
186 params[field] = response[field];
187 }
188 });
189 try {
190 const res = await API.get(`/api/oauth/telegram/login`, { params });
191 const { success, message, data } = res.data;
192 if (success) {
193 userDispatch({ type: 'login', payload: data });
194 localStorage.setItem('user', JSON.stringify(data));
195 showSuccess('登录成功!');
196 setUserData(data);
197 updateAPI();
198 navigate('/');
199 } else {
200 showError(message);
201 }
202 } catch (error) {
203 showError('登录失败,请重试');
204 }
205 };
206
207 // 包装的GitHub登录点击处理
208 const handleGitHubClick = () => {

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