Code Monkey home page Code Monkey logo

twisk's Issues

Provided database may have a duplicate key

Hello,

I am interested in Twirp for a fairly conventional RPC system and this starter kit seems perfect. I want to use the provided Postgres server to get up and running quick, but after changing the db string where instructed I get this for the ouput of step 3:

โžœ migration git:(master) โœ— go run main.go
2019/08/09 15:53:54 ERROR #23505 duplicate key value violates unique constraint "roles_pkey" (addr="52.18.106.191:5432")
exit status 1

Is it possible to get this repaired upstream? I am not that familiar with Postgres and want to hit the ground running.

How to write my cookies to browsers?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.