Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write my cookies to browsers? #1

Open
Michael2008S opened this issue Nov 23, 2018 · 0 comments
Open

How to write my cookies to browsers? #1

Michael2008S opened this issue Nov 23, 2018 · 0 comments

Comments

@Michael2008S
Copy link

Where I can write my cookies to browser ?

func (s *Service) Auth(c context.Context, req *iam.AuthReq) (*iam.AuthResp, error) {
	if err := req.Validate(); err != nil {
		return nil, err
	}

	dbCtx := s.db.WithContext(c)

	usr, err := s.udb.FindByAuth(dbCtx, req.Auth)
	if err != nil {
		return nil, invalidUserPW
	}

	if !s.sec.MatchesHash(usr.Password, req.Password) {
		return nil, invalidUserPW
	}

	token, err := s.tg.GenerateToken(&guidecentury.AuthUser{
		ID:       usr.ID,
		TenantID: usr.TenantID,
		Username: usr.Username,
		Email:    usr.Email,
		Role:     guidecentury.AccessRole(usr.RoleID),
	})

	if err != nil {
		return nil, err
	}

	uToken := xid.New().String()

	usr.UpdateLoginDetails(uToken)

	if err = s.udb.UpdateLastLogin(dbCtx, usr); err != nil {
		return nil, err
	}

	// Todo Write my cookies to browsers?


	return &iam.AuthResp{
		Token:        token,
		RefreshToken: uToken,
	}, nil
}

And how I write my cookies?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant