controller

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// validate failed
	ERROR_FLAG_VALIDATE_ACCOUNT_FAILED = iota + 1 // start with 1
	ERROR_FLAG_VALIDATE_REQUEST_BODY_FAILED
	ERROR_FLAG_VALIDATE_REQUEST_TOKEN_FAILED
	ERROR_FLAG_VALIDATE_REQUEST_PARAM_FAILED
	ERROR_FLAG_VALIDATE_VERIFICATION_CODE_FAILED
	ERROR_FLAG_PARSE_REQUEST_BODY_FAILED
	ERROR_FLAG_PARSE_REQUEST_URI_FAILED
	ERROR_FLAG_PARSE_INVITE_LINK_HASH_FAILED
	ERROR_FLAG_CAN_NOT_TRANSFER_OWNER_TO_PENDING_USER
	ERROR_FLAG_CAN_NOT_REMOVE_OWNER_FROM_TEAM
	ERROR_FLAG_SIGN_UP_EMAIL_MISMATCH
	ERROR_FLAG_OWNER_ROLE_MUST_BE_TRANSFERED
	ERROR_FLAG_PASSWORD_INVALIED
	ERROR_FLAG_TEAM_MUST_TRANSFERED_BEFORE_USER_SUSPEND
	ERROR_FLAG_INVITE_EMAIL_MISMATCH

	// can note create
	ERROR_FLAG_CAN_NOT_CREATE_USER
	ERROR_FLAG_CAN_NOT_CREATE_TEAM
	ERROR_FLAG_CAN_NOT_CREATE_TEAM_MEMBER
	ERROR_FLAG_CAN_NOT_CREATE_INVITE
	ERROR_FLAG_CAN_NOT_CREATE_INVITATION_CODE
	ERROR_FLAG_CAN_NOT_CREATE_DOMAIN
	ERROR_FLAG_CAN_NOT_CREATE_ACTION
	ERROR_FLAG_CAN_NOT_CREATE_RESOURCE
	ERROR_FLAG_CAN_NOT_CREATE_APP

	// can not get resource
	ERROR_FLAG_CAN_NOT_GET_USER
	ERROR_FLAG_CAN_NOT_GET_TEAM
	ERROR_FLAG_CAN_NOT_GET_TEAM_MEMBER
	ERROR_FLAG_CAN_NOT_GET_INVITE
	ERROR_FLAG_CAN_NOT_GET_INVITATION_CODE
	ERROR_FLAG_CAN_NOT_GET_DOMAIN
	ERROR_FLAG_CAN_NOT_GET_ACTION
	ERROR_FLAG_CAN_NOT_GET_RESOURCE
	ERROR_FLAG_CAN_NOT_GET_RESOURCE_META_INFO
	ERROR_FLAG_CAN_NOT_GET_APP
	ERROR_FLAG_CAN_NOT_GET_BUILDER_DESCRIPTION

	// can not update resource
	ERROR_FLAG_CAN_NOT_UPDATE_USER
	ERROR_FLAG_CAN_NOT_UPDATE_TEAM
	ERROR_FLAG_CAN_NOT_UPDATE_TEAM_MEMBER
	ERROR_FLAG_CAN_NOT_UPDATE_INVITE
	ERROR_FLAG_CAN_NOT_UPDATE_INVITATION_CODE
	ERROR_FLAG_CAN_NOT_UPDATE_DOMAIN
	ERROR_FLAG_CAN_NOT_UPDATE_ACTION
	ERROR_FLAG_CAN_NOT_UPDATE_RESOURCE
	ERROR_FLAG_CAN_NOT_UPDATE_APP

	// can not delete
	ERROR_FLAG_CAN_NOT_DELETE_USER
	ERROR_FLAG_CAN_NOT_DELETE_TEAM
	ERROR_FLAG_CAN_NOT_DELETE_TEAM_MEMBER
	ERROR_FLAG_CAN_NOT_DELETE_INVITE
	ERROR_FLAG_CAN_NOT_DELETE_INVITATION_CODE
	ERROR_FLAG_CAN_NOT_DELETE_DOMAIN
	ERROR_FLAG_CAN_NOT_DELETE_ACTION
	ERROR_FLAG_CAN_NOT_DELETE_RESOURCE
	ERROR_FLAG_CAN_NOT_DELETE_APP

	// can not other operation
	ERROR_FLAG_CAN_NOT_CHECK_TEAM_MEMBER
	ERROR_FLAG_CAN_NOT_DUPLICATE_APP
	ERROR_FLAG_CAN_NOT_RELEASE_APP
	ERROR_FLAG_CAN_NOT_TEST_RESOURCE_CONNECTION

	// permission failed
	ERROR_FLAG_ACCESS_DENIED
	ERROR_FLAG_TEAM_CLOSED_THE_PERMISSION
	ERROR_FLAG_EMAIL_ALREADY_USED
	ERROR_FLAG_EMAIL_HAS_BEEN_TAKEN
	ERROR_FLAG_INVITATION_CODE_ALREADY_USED
	ERROR_FLAG_INVITATION_LINK_UNAVALIABLE
	ERROR_FLAG_TEAM_IDENTIFIER_HAS_BEEN_TAKEN
	ERROR_FLAG_USER_ALREADY_JOINED_TEAM
	ERROR_FLAG_SIGN_IN_FAILED
	ERROR_FLAG_NO_SUCH_USER

	// call resource failed
	ERROR_FLAG_SEND_EMAIL_FAILED
	ERROR_FLAG_SEND_VERIFICATION_CODE_FAILED
	ERROR_FLAG_CREATE_LINK_FAILED
	ERROR_FLAG_CREATE_UPLOAD_URL_FAILED
	ERROR_FLAG_EXECUTE_ACTION_FAILED
	ERROR_FLAG_GENERATE_SQL_FAILED

	// internal failed
	ERROR_FLAG_BUILD_TEAM_MEMBER_LIST_FAILED
	ERROR_FLAG_BUILD_TEAM_CONFIG_FAILED
	ERROR_FLAG_BUILD_TEAM_PERMISSION_FAILED
	ERROR_FLAG_BUILD_USER_INFO_FAILED
	ERROR_FLAG_BUILD_APP_CONFIG_FAILED
	ERROR_FLAG_GENERATE_PASSWORD_FAILED
)
View Source
const PARAM_APP_ID = "appID"
View Source
const PARAM_ATTRIBUTE_ID = "attributeID"
View Source
const PARAM_AUTHORIZATION_TOKEN = "Authorization-Token"
View Source
const PARAM_FILE_NAME = "fileName"
View Source
const PARAM_FROM_ID = "fromID"
View Source
const PARAM_INVITE_LINK_HASH = "inviteLinkHash"
View Source
const PARAM_REQUEST_TOKEN = "Request-Token"
View Source
const PARAM_TARGET_TEAM_IDENTIFIER = "teamIdentifier"
View Source
const PARAM_TARGET_TEAM_MEMBER_ID = "targetTeamMemberID"
View Source
const PARAM_TARGET_USER_ID = "targetUserID"
View Source
const PARAM_TEAM_ID = "teamID"
View Source
const PARAM_TO_ID = "toID"
View Source
const PARAM_UNIT_ID = "unitID"
View Source
const PARAM_UNIT_TYPE = "unitType"
View Source
const PARAM_USER_ID = "userID"
View Source
const PARAM_USER_ROLE = "userRole"
View Source
const PARAM_VERSION = "version"

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Storage               *model.Storage
	Drive                 *model.Drive
	RequestTokenValidator *tokenvalidator.RequestTokenValidator
}

func NewController

func NewController(storage *model.Storage, drive *model.Drive, validator *tokenvalidator.RequestTokenValidator) *Controller

func (*Controller) CanAccess

func (controller *Controller) CanAccess(c *gin.Context)

func (*Controller) CanDelete

func (controller *Controller) CanDelete(c *gin.Context)

func (*Controller) CanManage

func (controller *Controller) CanManage(c *gin.Context)

func (*Controller) CanManageSpecial

func (controller *Controller) CanManageSpecial(c *gin.Context)

func (*Controller) CanModify

func (controller *Controller) CanModify(c *gin.Context)
func (controller *Controller) ConfigInviteLink(c *gin.Context)

func (*Controller) CreateUser

func (controller *Controller) CreateUser(c *gin.Context)

func (*Controller) DeleteOldInvite

func (controller *Controller) DeleteOldInvite(c *gin.Context, invite *model.Invite) error

func (*Controller) DeleteUser

func (controller *Controller) DeleteUser(c *gin.Context)

func (*Controller) DoesTeamInvitePermissionWasClosed

func (controller *Controller) DoesTeamInvitePermissionWasClosed(c *gin.Context, attrg *accesscontrol.AttributeGroup, team *model.Team) bool

func (*Controller) EmailAlreadyUsedByTeamMember

func (controller *Controller) EmailAlreadyUsedByTeamMember(c *gin.Context, email string, teamID int) (bool, *model.TeamMember)

func (*Controller) FeedbackBadRequest

func (controller *Controller) FeedbackBadRequest(c *gin.Context, errorFlag int, errorMessage string)

func (*Controller) FeedbackInternalServerError

func (controller *Controller) FeedbackInternalServerError(c *gin.Context, errorFlag int, errorMessage string)

func (*Controller) FeedbackInviteByEmail

func (controller *Controller) FeedbackInviteByEmail(c *gin.Context, invite *model.Invite)
func (controller *Controller) FeedbackInviteByLink(c *gin.Context, invite *model.Invite)

func (*Controller) FeedbackNewInviteByEmail

func (controller *Controller) FeedbackNewInviteByEmail(c *gin.Context, invite *model.Invite)

func (*Controller) FeedbackOK

func (controller *Controller) FeedbackOK(c *gin.Context, resp model.Response)

func (*Controller) ForgetPassword

func (controller *Controller) ForgetPassword(c *gin.Context)
func (controller *Controller) GenerateInviteLink(c *gin.Context)

Execute Phrase: - init phrase

  • get teamID
  • get userID
  • get userRole
  • fetch teamMember record
  • check attribute
  • fetch team record
  • check team permission

- execute invite phrase

  • fetch invite record
  • if invite already exists
  • true, feedback
  • generate new invite
  • create invite record
  • feedback

func (*Controller) GetAllTeamMember

func (controller *Controller) GetAllTeamMember(c *gin.Context)

func (*Controller) GetIntParamFromRequest

func (controller *Controller) GetIntParamFromRequest(c *gin.Context, paramName string) (int, error)

func (*Controller) GetMagicIntParamFromRequest

func (controller *Controller) GetMagicIntParamFromRequest(c *gin.Context, paramName string) (int, error)

func (*Controller) GetMyTeams

func (controller *Controller) GetMyTeams(c *gin.Context)

func (*Controller) GetStringParamFromHeader

func (controller *Controller) GetStringParamFromHeader(c *gin.Context, paramName string) (string, error)

func (*Controller) GetStringParamFromRequest

func (controller *Controller) GetStringParamFromRequest(c *gin.Context, paramName string) (string, error)

func (*Controller) GetTargetTeamByIdentifier

func (controller *Controller) GetTargetTeamByIdentifier(c *gin.Context)

func (*Controller) GetTargetUserByInternalRequest

func (controller *Controller) GetTargetUserByInternalRequest(c *gin.Context)

func (*Controller) GetTeamMember

func (controller *Controller) GetTeamMember(c *gin.Context)

func (*Controller) GetTeamPermission

func (controller *Controller) GetTeamPermission(c *gin.Context)

func (*Controller) GetUserAvatarUploadAddress

func (controller *Controller) GetUserAvatarUploadAddress(c *gin.Context)

func (*Controller) GetUserIDFromAuth

func (controller *Controller) GetUserIDFromAuth(c *gin.Context) (int, error)

@note: this param was setted by authenticator.JWTAuth() method

func (*Controller) GetVerificationCode

func (controller *Controller) GetVerificationCode(c *gin.Context)

generate and send verification code email

func (*Controller) InviteMemberByEmail

func (controller *Controller) InviteMemberByEmail(c *gin.Context)
func (controller *Controller) JoinByLink(c *gin.Context)

func (*Controller) Logout

func (controller *Controller) Logout(c *gin.Context)

func (*Controller) RemoveTeamMember

func (controller *Controller) RemoveTeamMember(c *gin.Context)
func (controller *Controller) RenewInviteLink(c *gin.Context)

func (*Controller) RetrieveUserByID

func (controller *Controller) RetrieveUserByID(c *gin.Context)

func (*Controller) SendInvite

func (controller *Controller) SendInvite(c *gin.Context, invite *model.Invite, team *model.Team, user *model.User) error

func (*Controller) SignIn

func (controller *Controller) SignIn(c *gin.Context)

user sign-in

func (*Controller) SignUp

func (controller *Controller) SignUp(c *gin.Context)

user sign-up signup -> check if email was used

<> with email invite token    -> check invite_token
                              -  create user
                              -  update team_member
                              -  delete invite_token
<> with link invite token     -> check invite_token
                              -  create team_member
                              -  create user
<> without token 				-> create user

func (*Controller) Status

func (controller *Controller) Status(c *gin.Context)

func (*Controller) StorageInvite

func (controller *Controller) StorageInvite(c *gin.Context, invite *model.Invite) error

func (*Controller) StorageTeamMemberByEmailInvite

func (controller *Controller) StorageTeamMemberByEmailInvite(c *gin.Context, invite *model.Invite) error

func (*Controller) TestMagicIntParamFromRequest

func (controller *Controller) TestMagicIntParamFromRequest(c *gin.Context, paramName string) (int, error)

test if Magic int exists in param, if not ,return 0 and an error.

func (*Controller) UpdateAvatar

func (controller *Controller) UpdateAvatar(c *gin.Context)

func (*Controller) UpdateInvite

func (controller *Controller) UpdateInvite(c *gin.Context, invite *model.Invite) error

func (*Controller) UpdateLanguage

func (controller *Controller) UpdateLanguage(c *gin.Context)

func (*Controller) UpdateNickname

func (controller *Controller) UpdateNickname(c *gin.Context)

func (*Controller) UpdatePassword

func (controller *Controller) UpdatePassword(c *gin.Context)

func (*Controller) UpdateTeamConfig

func (controller *Controller) UpdateTeamConfig(c *gin.Context)

func (*Controller) UpdateTeamMember

func (controller *Controller) UpdateTeamMember(c *gin.Context, teamMember *model.TeamMember) error

func (*Controller) UpdateTeamMemberRole

func (controller *Controller) UpdateTeamMemberRole(c *gin.Context)

global role config owner <MODIFY> owner -> any. NO, owner must be transferred before modify himself (a team must have an owner).

		  <MODIFY> admin, editor, viewer -> owner.                 YES, it's transfer owner action (when the owner transferred, the old owner became an admin).
       <MODIFY> admin, editor, viewer -> admin, editor, viewer. YES.

admin <MODIFY> owner -> any. NO.

		  <MODIFY> admin, editor, viewer -> owner.                 NO.
       <MODIFY> admin, editor, viewer -> admin, editor, viewer. YES.

editor <MODIFY> any -> any. NO. viewer <MODIFY> any -> any. NO.

func (*Controller) UpdateTeamPermission

func (controller *Controller) UpdateTeamPermission(c *gin.Context)

func (*Controller) ValidateAccount

func (controller *Controller) ValidateAccount(c *gin.Context)

func (*Controller) ValidateRequestTokenFromHeader

func (controller *Controller) ValidateRequestTokenFromHeader(c *gin.Context, input ...string) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL