third-login.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // import AsyncTask from './asyncTask'
  2. // const gTask = new AsyncTask()
  3. function fbStatusChangeCallback(response: any) {
  4. // Called with the results from FB.getLoginStatus().
  5. console.log('statusChangeCallback')
  6. console.log(response) // The current login status of the person.
  7. if (response.status === 'connected') {
  8. // Logged into your webpage and Facebook.
  9. fbConnect()
  10. }
  11. }
  12. function fbConnect() {
  13. // Testing Graph API after login. See statusChangeCallback() for when this call is made.
  14. FB.api('/me?fields=id,name,email', function (response: any) {
  15. console.log(response)
  16. location.href =
  17. '/api/user/facebook/callback?name=' +
  18. response.name +
  19. '&email=' +
  20. response.email
  21. })
  22. }
  23. export function FBLogin() {
  24. FB.login(fbStatusChangeCallback, { scope: 'public_profile,email' })
  25. }
  26. export function AppleLogin() {
  27. location.href = '/api/user/apple/login'
  28. }
  29. /* export async function renderGoogleLoginButton(parent: HTMLElement) {
  30. await gTask.promise
  31. google.accounts.id.renderButton(parent, {
  32. type: 'icon',
  33. shape: 'circle',
  34. theme: 'filled_black',
  35. width: 40,
  36. })
  37. } */
  38. /* window.addEventListener('load', () => {
  39. google.accounts.id.initialize({
  40. client_id:
  41. '393349837160-3opoqoo9l0gk9uimu212gp9uvm72406m.apps.googleusercontent.com',
  42. login_uri: import.meta.env.VITE_ORIGIN + '/api/user/google/callback',
  43. ux_mode: 'redirect',
  44. })
  45. gTask.done()
  46. }) */