MCPcopy Create free account
hub / github.com/dailydotdev/apps / onSocialRegistration

Function onSocialRegistration

packages/shared/src/hooks/useRegistration.ts:148–231  ·  view source on GitHub ↗
(provider: string)

Source from the content-addressed store, hash-verified

146 };
147
148 const onSocialRegistration = async (provider: string) => {
149 const additionalData = { timezone };
150
151 if (isNativeAuthSupported(provider)) {
152 const res = await iosNativeAuth(provider);
153 if (!res) {
154 return;
155 }
156 const result = await betterAuthSignInWithIdToken({
157 provider: provider.toLowerCase(),
158 token: res.token,
159 nonce: res.nonce,
160 additionalData,
161 });
162 if (result.error) {
163 logEvent({
164 event_name: AuthEventNames.RegistrationError,
165 extra: JSON.stringify({
166 provider,
167 error: result.error,
168 origin: 'betterauth native id token registration',
169 }),
170 });
171 return;
172 }
173 try {
174 const { data: boot } = await refetchBoot();
175 if (!boot.user) {
176 logEvent({
177 event_name: AuthEventNames.RegistrationError,
178 extra: JSON.stringify({
179 provider,
180 error: 'Missing user after Better Auth social registration',
181 origin: 'betterauth native id token registration boot',
182 }),
183 });
184 displayToast('An error occurred, please refresh the page.');
185 return;
186 }
187 } catch (error) {
188 logEvent({
189 event_name: AuthEventNames.RegistrationError,
190 extra: JSON.stringify({
191 provider,
192 error: getBetterAuthErrorMessage(
193 error,
194 'Failed to refresh Better Auth registration state',
195 ),
196 origin: 'betterauth native id token registration boot',
197 }),
198 });
199 displayToast('An error occurred, please refresh the page.');
200 return;
201 }
202 return;
203 }
204 const callbackURL = `${webappUrl}callback?login=true`;
205 const { url, error } = await getBetterAuthSocialRedirectData(

Callers 1

onRegisterFunction · 0.85

Calls 7

isNativeAuthSupportedFunction · 0.90
iosNativeAuthFunction · 0.90
logEventFunction · 0.85
displayToastFunction · 0.85

Tested by

no test coverage detected