From 8b2165e360545cf486de1234323ab0b67eea833d Mon Sep 17 00:00:00 2001 From: ahmetlutfu Date: Sat, 24 Oct 2020 12:40:05 +0300 Subject: [PATCH 1/4] added jwt token to json response --- handlers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handlers.go b/handlers.go index d102fe4..215272d 100644 --- a/handlers.go +++ b/handlers.go @@ -25,6 +25,10 @@ func respondAfterLogged(claims *claims.Claims, context *Context) { context.Auth.Redirector.Redirect(context.Writer, context.Request, "login") }).With([]string{"json"}, func() { // TODO write json token + var response = map[string]interface{}{} + response["access_token"] = context.Auth.SessionStorer.SignedToken(claims) + response["success"] = true + json.NewEncoder(context.Writer).Encode(&response) }).Respond(context.Request) } From e725c419854a5c1919e3cef13cd22ac5fd07a0f2 Mon Sep 17 00:00:00 2001 From: lutfuahmet Date: Tue, 5 Jan 2021 20:25:17 +0300 Subject: [PATCH 2/4] fixed mail from issue --- .idea/auth.iml | 9 ++++++ .idea/modules.xml | 8 ++++++ .idea/vcs.xml | 6 ++++ .idea/workspace.xml | 43 ++++++++++++++++++++++++++++ providers/password/confirm.go | 2 ++ providers/password/reset_password.go | 2 ++ 6 files changed, 70 insertions(+) create mode 100644 .idea/auth.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/auth.iml b/.idea/auth.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/auth.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..573ddca --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..b4dcb42 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + \ No newline at end of file diff --git a/providers/password/confirm.go b/providers/password/confirm.go index fc04e41..6db16e9 100644 --- a/providers/password/confirm.go +++ b/providers/password/confirm.go @@ -4,6 +4,7 @@ import ( "errors" "html/template" "net/mail" + "os" "path" "reflect" "time" @@ -40,6 +41,7 @@ var DefaultConfirmationMailer = func(email string, context *auth.Context, claims return context.Auth.Mailer.Send( mailer.Email{ TO: []mail.Address{{Address: email}}, + From: &mail.Address{Address: os.Getenv("SMTP_FROM")}, Subject: ConfirmationMailSubject, }, mailer.Template{ Name: "auth/confirmation", diff --git a/providers/password/reset_password.go b/providers/password/reset_password.go index 3179cca..08b887c 100644 --- a/providers/password/reset_password.go +++ b/providers/password/reset_password.go @@ -2,6 +2,7 @@ package password import ( "net/mail" + "os" "path" "reflect" "strings" @@ -36,6 +37,7 @@ var DefaultResetPasswordMailer = func(email string, context *auth.Context, claim mailer.Email{ TO: []mail.Address{{Address: email}}, Subject: ResetPasswordMailSubject, + From: &mail.Address{Address: os.Getenv("SMTP_FROM")}, }, mailer.Template{ Name: "auth/reset_password", Data: context, From 295dc2ff0fefac6ec9f30b2d9ab72335c7fbaa2a Mon Sep 17 00:00:00 2001 From: lutfuahmet Date: Tue, 5 Jan 2021 20:28:18 +0300 Subject: [PATCH 3/4] gitignore update --- .gitignore | 1 + .idea/auth.iml | 9 --------- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ .idea/workspace.xml | 43 ------------------------------------------- 5 files changed, 1 insertion(+), 66 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/auth.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/.idea/auth.iml b/.idea/auth.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/auth.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 573ddca..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index b4dcb42..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - \ No newline at end of file From 80bdb7be1fff430fb3868688cca43337b3c8ce8a Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Sat, 16 Mar 2024 00:40:52 +0300 Subject: [PATCH 4/4] fixed auth issue --- handlers.go | 2 ++ providers/password/handlers.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/handlers.go b/handlers.go index 215272d..52072c0 100644 --- a/handlers.go +++ b/handlers.go @@ -2,9 +2,11 @@ package auth import ( "crypto/md5" + "encoding/json" "fmt" "html/template" "mime" + "net/http" "path" "path/filepath" diff --git a/providers/password/handlers.go b/providers/password/handlers.go index b8e7a94..a63e005 100644 --- a/providers/password/handlers.go +++ b/providers/password/handlers.go @@ -75,6 +75,8 @@ var DefaultRegisterHandler = func(context *auth.Context) (*claims.Claims, error) schema.UID = authInfo.UID schema.Email = authInfo.UID schema.RawInfo = req + schema.FirstName = req.Form.Get("first_name") + schema.LastName = req.Form.Get("last_name") currentUser, authInfo.UserID, err = context.Auth.UserStorer.Save(&schema, context) if err != nil { @@ -83,7 +85,7 @@ var DefaultRegisterHandler = func(context *auth.Context) (*claims.Claims, error) // create auth identity authIdentity := reflect.New(utils.ModelType(context.Auth.Config.AuthIdentityModel)).Interface() - if err = tx.Where("provider = ? AND uid = ?", authInfo.Provider, authInfo.UID).FirstOrCreate(authIdentity).Error; err == nil { + if err = tx.Where("provider = ? AND uid = ?", authInfo.Provider, authInfo.UID).Attrs("EncryptedPassword", authInfo.EncryptedPassword).Attrs("UserID", authInfo.UserID).Attrs("Provider", authInfo.Provider).Attrs("UID", authInfo.UID).FirstOrCreate(authIdentity).Error; err == nil { if provider.Config.Confirmable { context.SessionStorer.Flash(context.Writer, req, session.Message{Message: ConfirmFlashMessage, Type: "success"}) err = provider.Config.ConfirmMailer(schema.Email, context, authInfo.ToClaims(), currentUser)