From 9f9d1e64e45d75a927c517eceede054d44359d85 Mon Sep 17 00:00:00 2001 From: geek Date: Fri, 4 May 2018 16:44:10 +0900 Subject: [PATCH] ing --- service/member-service.go | 54 ++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/service/member-service.go b/service/member-service.go index 30d49c3..26b7443 100644 --- a/service/member-service.go +++ b/service/member-service.go @@ -16,8 +16,6 @@ import ( "git.loafle.net/overflow/gateway/external/grpc" "github.com/valyala/fasthttp" - "net/url" - "github.com/dgrijalva/jwt-go" ) @@ -36,20 +34,11 @@ type MemberService struct { _Signin cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/signin', params='[signinID, signinPW]')"` _SigninByCookie cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/signin_cookie', params='[authToken]')"` _Signup cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/signup', params='[member, password]')"` - _EmailConfirm cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='GET', entry='/account/email_confirm', params='[token]')"` - _ForgotPassword cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/forgot_password', params='[signinID]')"` - _ResetPwConfirm cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/reset_pw_confirm', params='[pw, key]')"` -} + _ConfirmEmail cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='GET', entry='/account/confirm_email', params='[token]')"` + _SendEmailPw cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/send_email_pw', params='[signinID]')"` + _ConfirmResetPw cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='GET', entry='/account/confirm_reset_pw', params='[token]')"` -func (ms *MemberService) EmailConfirm(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, token string) error { - var c fasthttp.Cookie - c.SetKey("cookie-name") - c.SetValue("cookie-value") - ctx.Response.Header.SetCookie(&c) - - ctx.SetBody([]byte("DDDDDDD")) - - return nil + _ResetPassword cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/reset_password', params='[signinID, newPW]')"` } type SigninResult struct { @@ -154,7 +143,7 @@ func (ms *MemberService) Signup(servletCtx server.ServletCtx, ctx *fasthttp.Requ return nil } -func (ms *MemberService) ForgotPassword(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, signinID string) error { +func (ms *MemberService) SendEmailPw(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, signinID string) error { gRPCCtx := context.Background() r, err := grpc.Exec(gRPCCtx, "MemberService.sendEmailForPassword", signinID) @@ -167,12 +156,39 @@ func (ms *MemberService) ForgotPassword(servletCtx server.ServletCtx, ctx *fasth return nil } +func (ms *MemberService) ConfirmEmail(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, token string) error { + gRPCCtx := context.Background() + + r, err := grpc.Exec(gRPCCtx, "EmailAuthService.readBySignupAuthKey", token) + if nil != err { + return err + } + ctx.SetBody([]byte(r)) + + return nil +} + // Todo id QueryEscape Test -func (ms *MemberService) ResetPwConfirm(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, pw string, key string) error { +func (ms *MemberService) ConfirmResetPw(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, token string) error { gRPCCtx := context.Background() - r, err := grpc.Exec(gRPCCtx, "MemberService.resetPassword", url.QueryEscape(key), pw) + r, err := grpc.Exec(gRPCCtx, "EmailAuthService.readByPwAuthKey", token) + if nil != err { + return err + } + + // Todo Redirect Member_WEBAPP + ctx.SetBody([]byte(r)) + + return nil +} + +func (ms *MemberService) ResetPassword(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx, signinID string, newPw string) error { + + gRPCCtx := context.Background() + + r, err := grpc.Exec(gRPCCtx, "MemberService.resetPassword", signinID, newPw) if nil != err { return err } @@ -181,3 +197,5 @@ func (ms *MemberService) ResetPwConfirm(servletCtx server.ServletCtx, ctx *fasth return nil } + +