处理 有问题的handler

This commit is contained in:
eson
2023-07-21 14:20:21 +08:00
parent 44a3666d68
commit 373d5dca45
74 changed files with 174 additions and 3485 deletions

View File

@@ -1,6 +1,7 @@
package logic
import (
"fmt"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"log"
@@ -37,14 +38,32 @@ func NewUserGoogleLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U
}
}
func (l *UserGoogleLoginLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
log.Println(r, w)
}
// func (l *UserGoogleLoginLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// log.Println(r, w)
// }
func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) {
if l.redirectUrl != "" {
http.Redirect(w, r, "http://localhost:9900/assistant/redirect?url="+url.QueryEscape(l.redirectUrl), http.StatusFound)
}
html := fmt.Sprintf(`
<!DOCTYPE html>
<html>
<head>
<title>Redirect</title>
<script type="text/javascript">
window.onload = function() {
window.location = "%s";
}
</script>
</head>
<body>
</body>
</html>
`, l.redirectUrl)
fmt.Fprintln(w, html)
// if l.redirectUrl != "" {
// http.Redirect(w, r, "http://localhost:9900/api/assistant/redirect?url="+url.QueryEscape(l.redirectUrl), http.StatusFound)
// }
}
func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, userinfo *auth.UserInfo) (resp *basic.Response) {
@@ -89,6 +108,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
log.Println(r.Json())
googleId := r.Json().Get("id").Int()
l.redirectUrl = "http://localhost:9900/oauth?token=21321123"
return resp.Set(304, "21321321")
user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId)
log.Println(user)