feat: assign users to teams via OIDC claims #1393
|
@ -111,6 +111,19 @@ This document describes the different errors Vikunja can return.
|
|||
| 6010 | 400 | There are no oidc teams found for the user. |
|
||||
|
||||
|
||||
| ErrorCode | HTTP Status Code | Description |
|
||||
|-----------|------------------|-------------|
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
| 6001 | 400 | The team name cannot be emtpy. |
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
Please add punctuation. Please add punctuation.
|
||||
| 6002 | 404 | The team does not exist. |
|
||||
| 6004 | 409 | The team already has access to that namespace or list. |
|
||||
| 6005 | 409 | The user is already a member of that team. |
|
||||
| 6006 | 400 | Cannot delete the last team member. |
|
||||
| 6007 | 403 | The team does not have access to the list to perform that action. |
|
||||
| 6008 | 400 | There are no teams found with that team name |
|
||||
| 6009 | 400 | There is no oidc team with that team name and oidcId |
|
||||
| 6010 | 400 | There are no oidc teams found for the user |
|
||||
|
||||
|
||||
|
||||
## User Project Access
|
||||
|
||||
|
|
|
@ -1229,22 +1229,46 @@ type ErrTeamsDoNotExist struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
// IsErrTeamDoNotExist checks if an error is ErrTeamDoesNotExist.
|
||||
// IsErrTeamsDoNotExist checks if an error is ErrTeamsDoNotExist.
|
||||
func IsErrTeamsDoNotExist(err error) bool {
|
||||
_, ok := err.(ErrTeamsDoNotExist)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrTeamsDoNotExist) Error() string {
|
||||
return fmt.Sprintf("Team does not exist [Team Name: %v]", err.Name)
|
||||
return fmt.Sprintf("No teams with that name exist [Team Name: %v]", err.Name)
|
||||
}
|
||||
|
||||
// ErrCodeTeamDoesNotExist holds the unique world-error code of this error
|
||||
// ErrCodeTeamsDoesNotExist holds the unique world-error code of this error
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
Error message should be Error message should be `No Team with that name and valid oidcId could be found.` (same for the `Error()
konrad
commented
Error message should be Error message should be `No Team with that name and valid oidcId could be found.` (same for the `Error()
|
||||
const ErrCodeTeamsDoNotExist = 6008
|
||||
|
||||
// HTTPError holds the http error description
|
||||
func (err ErrTeamsDoNotExist) HTTPError() web.HTTPError {
|
||||
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No team with given name exists."}
|
||||
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No teams with that name exist"}
|
||||
}
|
||||
|
||||
// ErrOIDCTeamDoesNotExist represents an error where a team with specified name and specified oidcId property does not exist
|
||||
type ErrOIDCTeamDoesNotExist struct {
|
||||
OidcId string
|
||||
Name string
|
||||
}
|
||||
|
||||
// IsErrOIDCTeamDoesNotExist checks if an error is ErrOIDCTeamDoesNotExist.
|
||||
func IsErrOIDCTeamDoesNotExist(err error) bool {
|
||||
_, ok := err.(ErrOIDCTeamDoesNotExist)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrOIDCTeamDoesNotExist) Error() string {
|
||||
return fmt.Sprintf("No Team with that name and valid property oidcId could be found [Team Name: %v] [OidcId : %v] ", err.Name, err.OidcId)
|
||||
}
|
||||
|
||||
// ErrCodeTeamDoesNotExist holds the unique world-error code of this error
|
||||
const ErrCodeOIDCTeamDoesNotExist = 6009
|
||||
|
||||
// HTTPError holds the http error description
|
||||
func (err ErrOIDCTeamDoesNotExist) HTTPError() web.HTTPError {
|
||||
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Team with that name and valid property oidcId could be found."}
|
||||
}
|
||||
|
||||
// ErrOIDCTeamsDoNotExistForUser represents an error where an oidcTeam does not exist for the user
|
||||
|
@ -1254,20 +1278,20 @@ type ErrOIDCTeamsDoNotExistForUser struct {
|
|||
|
||||
// IsErrOIDCTeamsDoNotExistForUser checks if an error is ErrOIDCTeamsDoNotExistForUser.
|
||||
func IsErrOIDCTeamsDoNotExistForUser(err error) bool {
|
||||
_, ok := err.(ErrTeamDoesNotExist)
|
||||
_, ok := err.(ErrOIDCTeamsDoNotExistForUser)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrOIDCTeamsDoNotExistForUser) Error() string {
|
||||
return fmt.Sprintf("No Oidc exists for User [User ID: %d]", err.UserID)
|
||||
return fmt.Sprintf("No Teams with property oidcId could be found for User [User ID: %d]", err.UserID)
|
||||
}
|
||||
|
||||
// ErrCodeTeamDoesNotExist holds the unique world-error code of this error
|
||||
const ErrCodeOIDCTeamsDoNotExistForUser = 6009
|
||||
const ErrCodeOIDCTeamsDoNotExistForUser = 6010
|
||||
|
||||
// HTTPError holds the http error description
|
||||
func (err ErrOIDCTeamsDoNotExistForUser) HTTPError() web.HTTPError {
|
||||
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "This team does not exist."}
|
||||
return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Teams with property oidcId could be found for User."}
|
||||
}
|
||||
|
||||
// ====================
|
||||
|
|
|
@ -159,7 +159,7 @@ func GetTeamByOidcIDAndName(s *xorm.Session, oidcID string, teamName string) (te
|
|||
if exists && err == nil {
|
||||
return team, nil
|
||||
}
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
This error message should contain the name as well. This error message should contain the name as well.
|
||||
return team, ErrTeamsDoNotExist{oidcID}
|
||||
return team, ErrOIDCTeamDoesNotExist{teamName, oidcID}
|
||||
}
|
||||
|
||||
func FindAllOidcTeamIDsForUser(s *xorm.Session, userID int64) (ts []int64, err error) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user
These error codes are duplicated with the block above.
Done.