// Register satisfies rpc.Register function on AuthService proto definition
Register satisfies rpc.Register function on AuthService proto definition
// Register satisfies rpc . Register function on AuthService proto definition
func (ad *SysAccountRepo) Register(ctx context.Context, in *pkg.RegisterRequest) (*pkg.RegisterResponse, error) {
	if in == nil {
		return nil, status.Errorf(codes.InvalidArgument, "invalid argument")
	}
	if in.Password != in.PasswordConfirm {
		return nil, status.Errorf(codes.InvalidArgument, "password mismatch")
	}
	accountId := coredb.NewID()
	now := timestampNow()
	newAcc := &pkg.Account{
		Id:       accountId,
		Email:    in.Email,
		Password: in.Password,
		Role: &pkg.UserRoles{
			Role: 2,
			All:  false,
		},
		CreatedAt: now,
		UpdatedAt: now,
		Disabled:  false,
		Fields:    &pkg.UserDefinedFields{},
		Survey:    &pkg.UserDefinedFields{},
		Verified:  false,
	}
	acc, err := ad.store.InsertFromPkgAccountRequest(newAcc)
	if err != nil {
		return &pkg.RegisterResponse{
			Success:     false,
			ErrorReason: err.Error(),
		}, err
	}
	vtoken, _, err := ad.genVerificationToken(&coredb.QueryParams{Params: map[string]interface{}{"email": in.Email}})
	if err != nil {
		return nil, err
	}
	return &pkg.RegisterResponse{
		Success:     true,
		SuccessMsg:  fmt.Sprintf("Successfully created user: %s as Guest", in.Email),
		VerifyToken: vtoken,
		ErrorReason: "",
		TempUserId:  acc.ID,
	}, nil
}
func ( ad * SysAccountRepo ) Register ( ctx context . Context , in * pkg . RegisterRequest ) ( * pkg . RegisterResponse , error ) { if in == nil { return nil , status . Errorf ( codes . InvalidArgument , " " ) } if in . Password != in . PasswordConfirm { return nil , status . Errorf ( codes . InvalidArgument , " " ) } accountId := coredb . NewID ( ) now := timestampNow ( ) newAcc := & pkg . Account { Id : accountId , Email : in . Email , Password : in . Password , Role : & pkg . UserRoles { Role : 2 , All : false , } , CreatedAt : now , UpdatedAt : now , Disabled : false , Fields : & pkg . UserDefinedFields { } , Survey : & pkg . UserDefinedFields { } , Verified : false , } acc , err := ad . store . InsertFromPkgAccountRequest ( newAcc ) if err != nil { return & pkg . RegisterResponse { Success : false , ErrorReason : err . Error ( ) , } , err } vtoken , _ , err := ad . genVerificationToken ( & coredb . QueryParams { Params : map [ string ] interface { } { " " : in . Email } } ) if err != nil { return nil , err } return & pkg . RegisterResponse { Success : true , SuccessMsg : fmt . Sprintf ( " " , in . Email ) , VerifyToken : vtoken , ErrorReason : " " , TempUserId : acc . ID , } , nil }
Register satisfies rpc.Register function on AuthService proto definition
Register satisfies rpc . Register function on AuthService proto definition
// New user will be assigned GUEST role and no Org / Project for now. // TODO @gutterbacon: subject to change.