Example #1
0
File: user.go Project: Gr1N/pacman
package models

import (
	"github.com/pborman/uuid"

	"github.com/Gr1N/pacman/modules/errors"
	"github.com/Gr1N/pacman/modules/helpers"
)

var (
	errUserNotExist = errors.New(
		"user_not_exist", "User does not exist")
)

// User represents the object of individual user.
type User struct {
	Model

	Tokens   []Token
	Services []Service
}

// CreateUserByService creates record of a new user using given service.
func CreateUserByService(serviceName, serviceAccessToken string, userServiceID int64,
	userServiceName, userServiceEmail string) (*User, error) {

	user := User{
		Services: []Service{{
			Name:             serviceName,
			AccessToken:      serviceAccessToken,
			UserServiceID:    userServiceID,
Example #2
0
package oauth2

import (
	"github.com/Gr1N/pacman/modules/errors"
)

var (
	errServiceNotSupported = errors.New(
		"authorization_service_not_supported", "Specified service is not supported")
	errServiceUnavailable = errors.New(
		"authorization_service_unavailable", "Authorization service temporary unavailable")
	errStateInvalid = errors.New(
		"state_invalid", "State value is not valid")
	errCodeInvalid = errors.New(
		"authorization_code_invalid", "Authorization code invalid or issued for another service")
	errTokenInvalid = errors.New(
		"access_token_invalid", "Access token invalid or expired")
)
Example #3
0
package models

import (
	"github.com/Gr1N/pacman/modules/errors"
)

var (
	errServiceNotExist = errors.New(
		"service_not_exist", "User service does not exist")
)

// Service represents the object of external service.
type Service struct {
	Model

	UserID int64 `sql:"not null;unique_index:idx_userid_userserviceid"`

	Name string `sql:"not null;index"`

	AccessToken string `sql:"not null"`

	UserServiceID    int64 `sql:"not null;unique_index:idx_userid_userserviceid"`
	UserServiceName  string
	UserServiceEmail string

	Repos []Repo
}
Example #4
0
File: token.go Project: Gr1N/pacman
package models

import (
	"github.com/Gr1N/pacman/modules/errors"
)

var (
	errUserTokenNotExist = errors.New(
		"service_not_exist", "User token does not exist")
)

type Token struct {
	Model

	UserID int64 `sql:"not null;unique_index:idx_userid_value"`

	Audience string `sql:"not null"`
	Value    string `sql:"not null;unique_index:idx_userid_value"`
}