update server error response and lazy load img
This commit is contained in:
parent
36c71eda38
commit
59407840cd
3 changed files with 7 additions and 1 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
class="w-6 h-6"
|
class="w-6 h-6"
|
||||||
src="assets/google-color.svg"
|
src="assets/google-color.svg"
|
||||||
alt="google logo"
|
alt="google logo"
|
||||||
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
<span>Login with @foth.co.th Google account</span>
|
<span>Login with @foth.co.th Google account</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<p>dashboard works!</p>
|
<p>dashboard works!</p>
|
||||||
<div *ngIf="userInfo">
|
<div *ngIf="userInfo">
|
||||||
<img [src]="userInfo.image" />
|
<img [src]="userInfo.image" loading="lazy" />
|
||||||
<p>Hi {{ userInfo.username }}</p>
|
<p>Hi {{ userInfo.username }}</p>
|
||||||
<p>Your email is {{ userInfo.email }}</p>
|
<p>Your email is {{ userInfo.email }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,11 @@ func (ar *AuthRouter) Route(r chi.Router) {
|
||||||
token.RefreshToken = cookie.Value
|
token.RefreshToken = cookie.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if token.AccessToken == "" && token.RefreshToken == "" {
|
||||||
|
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// get user info
|
// get user info
|
||||||
client := ar.gConfig.Client(r.Context(), token)
|
client := ar.gConfig.Client(r.Context(), token)
|
||||||
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue