-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Google Login button disappearing issue #3197
Open
GspikeHalo
wants to merge
16
commits into
master
Choose a base branch
from
fix-google-login-button
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+187
−76
Open
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7b48734
fix google login button
GspikeHalo 199bcb5
Merge branch 'master' into fix-google-login-button
kunwp1 20536ff
Merge branch 'master' into fix-google-login-button
GspikeHalo 6ea854e
use promise, use window.google
GspikeHalo 4eb6d53
Merge branch 'master' into fix-google-login-button
GspikeHalo b4573e3
Merge branch 'master' into fix-google-login-button
GspikeHalo 0dbe79f
Merge branch 'master' into fix-google-login-button
GspikeHalo 4d853ac
use angularx social login
GspikeHalo ea41a24
update
GspikeHalo 3204ba2
get client id from backend
GspikeHalo b3812dc
add test file
GspikeHalo 4e6be6a
update test file
GspikeHalo b1e79f6
Merge branch 'master' into fix-google-login-button
GspikeHalo d68b776
Enable One Tap and refactor the program to adapt to the enabled One Tap.
GspikeHalo 3d2fd0f
fix unit test
GspikeHalo 6ac8cbd
fix unit test
GspikeHalo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 4 additions & 29 deletions
33
core/gui/src/app/common/service/user/google-auth.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,15 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Subject } from "rxjs"; | ||
import { Observable } from "rxjs"; | ||
import { HttpClient } from "@angular/common/http"; | ||
import { AppSettings } from "../../app-setting"; | ||
declare var window: any; | ||
export interface CredentialResponse { | ||
client_id: string; | ||
credential: string; | ||
select_by: string; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class GoogleAuthService { | ||
private _googleCredentialResponse = new Subject<CredentialResponse>(); | ||
constructor(private http: HttpClient) {} | ||
public googleAuthInit(parent: HTMLElement | null) { | ||
this.http.get(`${AppSettings.getApiEndpoint()}/auth/google/clientid`, { responseType: "text" }).subscribe({ | ||
next: response => { | ||
window.onGoogleLibraryLoad = () => { | ||
window.google.accounts.id.initialize({ | ||
client_id: response, | ||
callback: (auth: CredentialResponse) => { | ||
this._googleCredentialResponse.next(auth); | ||
}, | ||
}); | ||
window.google.accounts.id.renderButton(parent, { width: 200 }); | ||
window.google.accounts.id.prompt(); | ||
}; | ||
}, | ||
error: (err: unknown) => { | ||
console.error(err); | ||
}, | ||
}); | ||
} | ||
|
||
get googleCredentialResponse() { | ||
return this._googleCredentialResponse.asObservable(); | ||
getClientId(): Observable<{ clientId: string }> { | ||
return this.http.get<{ clientId: string }>(`${AppSettings.getApiEndpoint()}/auth/google/clientid`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,9 @@ nz-content { | |
.hidden { | ||
display: none; | ||
} | ||
|
||
#nav { | ||
max-width: 100%; | ||
max-height: 100%; | ||
overflow: hidden; | ||
} |
6 changes: 6 additions & 0 deletions
6
core/gui/src/app/dashboard/component/user/google-login/google-login.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
<asl-google-signin-button | ||
type="standard" | ||
size="large" | ||
width="200"></asl-google-signin-button> | ||
</div> |
45 changes: 45 additions & 0 deletions
45
core/gui/src/app/dashboard/component/user/google-login/google-login.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { GoogleLoginComponent } from "./google-login.component"; | ||
import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
import { RouterTestingModule } from "@angular/router/testing"; | ||
import { UserService } from "../../../../common/service/user/user.service"; | ||
import { SocialAuthService } from "@abacritt/angularx-social-login"; | ||
import { of } from "rxjs"; | ||
|
||
describe("GoogleLoginComponent", () => { | ||
let component: GoogleLoginComponent; | ||
let fixture: ComponentFixture<GoogleLoginComponent>; | ||
let userService: jasmine.SpyObj<UserService>; | ||
let socialAuthService: jasmine.SpyObj<SocialAuthService>; | ||
|
||
beforeEach(async () => { | ||
const userServiceSpy = jasmine.createSpyObj("UserService", ["googleLogin"]); | ||
const socialAuthServiceSpy = jasmine.createSpyObj("SocialAuthService", [], { | ||
authState: of({ idToken: "mock-id-token" }), | ||
}); | ||
|
||
await TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule, RouterTestingModule], | ||
declarations: [GoogleLoginComponent], | ||
providers: [ | ||
{ provide: UserService, useValue: userServiceSpy }, | ||
{ provide: SocialAuthService, useValue: socialAuthServiceSpy }, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GoogleLoginComponent); | ||
component = fixture.componentInstance; | ||
userService = TestBed.inject(UserService) as jasmine.SpyObj<UserService>; | ||
socialAuthService = TestBed.inject(SocialAuthService) as jasmine.SpyObj<SocialAuthService>; | ||
}); | ||
|
||
it("should create the component", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it("should render Google Sign-In button", () => { | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
const button = compiled.querySelector("asl-google-signin-button"); | ||
expect(button).toBeTruthy(); | ||
}); | ||
}); |
17 changes: 7 additions & 10 deletions
17
core/gui/src/app/dashboard/component/user/google-login/google-login.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to disable oneTap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that when I enable One Tap, a message 'PR' appears in my console.
I noticed that if I disable it, the message does not appear. If One Tap is necessary, I can try to see if I can eliminate this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it is difficult to eliminate this issue if you enable One Tap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the log provided by Google for debugging purposes, intended for developers. The purpose of this log is to provide information on why OneTap was skipped or did not appear. It means this console message should only appear on localhost, so there’s no need to worry about it. For more details, search for
"skipped"
in the GSI Client JavaScript file available at: https://accounts.google.com/gsi/client. Also: https://developers.google.com/identity/gsi/web/guides/featuresThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Let's revisit this when the message appears in the production website. @GspikeHalo Let's remove the
oneTapEnabled: false
.