This commit is contained in:
geek 2018-05-04 16:44:10 +09:00
parent dcf21f9545
commit 9f9d1e64e4

View File

@ -16,8 +16,6 @@ import (
"git.loafle.net/overflow/gateway/external/grpc" "git.loafle.net/overflow/gateway/external/grpc"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"net/url"
"github.com/dgrijalva/jwt-go" "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]')"` _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]')"` _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]')"` _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]')"` _ConfirmEmail cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='GET', entry='/account/confirm_email', params='[token]')"`
_ForgotPassword cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/forgot_password', params='[signinID]')"` _SendEmailPw cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/send_email_pw', params='[signinID]')"`
_ResetPwConfirm cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/reset_pw_confirm', params='[pw, key]')"` _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 { _ResetPassword cda.MethodAnnotation `annotation:"@overflow:RequestMapping(method='POST', entry='/account/reset_password', params='[signinID, newPW]')"`
var c fasthttp.Cookie
c.SetKey("cookie-name")
c.SetValue("cookie-value")
ctx.Response.Header.SetCookie(&c)
ctx.SetBody([]byte("DDDDDDD"))
return nil
} }
type SigninResult struct { type SigninResult struct {
@ -154,7 +143,7 @@ func (ms *MemberService) Signup(servletCtx server.ServletCtx, ctx *fasthttp.Requ
return nil 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() gRPCCtx := context.Background()
r, err := grpc.Exec(gRPCCtx, "MemberService.sendEmailForPassword", signinID) r, err := grpc.Exec(gRPCCtx, "MemberService.sendEmailForPassword", signinID)
@ -167,12 +156,39 @@ func (ms *MemberService) ForgotPassword(servletCtx server.ServletCtx, ctx *fasth
return nil 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 // 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() 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 { if nil != err {
return err return err
} }
@ -181,3 +197,5 @@ func (ms *MemberService) ResetPwConfirm(servletCtx server.ServletCtx, ctx *fasth
return nil return nil
} }