chore: rename Citadel to Taskcafe
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var jwtKey = []byte("citadel_test_key")
|
||||
var jwtKey = []byte("taskcafe_test_key")
|
||||
|
||||
type RestrictedMode string
|
||||
|
||||
|
@ -5,11 +5,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const CitadelConfDirEnvName = "CITADEL_CONFIG_DIR"
|
||||
const TaskcafeConfDirEnvName = "TASKCAFE_CONFIG_DIR"
|
||||
|
||||
const CitadelAppConf = "citadel"
|
||||
const TaskcafeAppConf = "taskcafe"
|
||||
|
||||
const mainDescription = `citadel is an open soure project management
|
||||
const mainDescription = `Taskcafé is an open soure project management
|
||||
system written in Golang & React.`
|
||||
|
||||
var (
|
||||
@ -28,7 +28,7 @@ var verbose bool
|
||||
var noColor bool
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "citadel",
|
||||
Use: "taskcafe",
|
||||
Long: mainDescription,
|
||||
Version: version,
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/golang-migrate/migrate/v4/source/file"
|
||||
"github.com/golang-migrate/migrate/v4/source/httpfs"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jordanknott/project-citadel/internal/config"
|
||||
"github.com/jordanknott/project-citadel/internal/migrations"
|
||||
"github.com/jordanknott/taskcafe/internal/config"
|
||||
"github.com/jordanknott/taskcafe/internal/migrations"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jordanknott/project-citadel/internal/config"
|
||||
"github.com/jordanknott/project-citadel/internal/route"
|
||||
"github.com/jordanknott/taskcafe/internal/config"
|
||||
"github.com/jordanknott/taskcafe/internal/route"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,9 @@ import (
|
||||
"github.com/99designs/gqlgen/graphql/handler/transport"
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/project-citadel/internal/auth"
|
||||
"github.com/jordanknott/project-citadel/internal/config"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
"github.com/jordanknott/taskcafe/internal/config"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
)
|
||||
|
||||
// NewHandler returns a new graphql endpoint handler.
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
)
|
||||
|
||||
func GetOwnedList(ctx context.Context, r db.Repository, user db.UserAccount) (*OwnedList, error) {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
)
|
||||
|
||||
type AddTaskLabelInput struct {
|
||||
|
@ -5,8 +5,8 @@ package graph
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/jordanknott/project-citadel/internal/config"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/config"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
)
|
||||
|
||||
type Resolver struct {
|
||||
|
@ -1,560 +0,0 @@
|
||||
scalar Time
|
||||
scalar UUID
|
||||
scalar Upload
|
||||
|
||||
enum RoleCode {
|
||||
owner
|
||||
admin
|
||||
member
|
||||
observer
|
||||
}
|
||||
|
||||
type ProjectLabel {
|
||||
id: ID!
|
||||
createdDate: Time!
|
||||
labelColor: LabelColor!
|
||||
name: String
|
||||
}
|
||||
|
||||
type LabelColor {
|
||||
id: ID!
|
||||
name: String!
|
||||
position: Float!
|
||||
colorHex: String!
|
||||
}
|
||||
|
||||
type TaskLabel {
|
||||
id: ID!
|
||||
projectLabel: ProjectLabel!
|
||||
assignedDate: Time!
|
||||
}
|
||||
|
||||
type ProfileIcon {
|
||||
url: String
|
||||
initials: String
|
||||
bgColor: String
|
||||
}
|
||||
|
||||
type Member {
|
||||
id: ID!
|
||||
role: Role!
|
||||
fullName: String!
|
||||
username: String!
|
||||
profileIcon: ProfileIcon!
|
||||
}
|
||||
|
||||
type RefreshToken {
|
||||
id: ID!
|
||||
userId: UUID!
|
||||
expiresAt: Time!
|
||||
createdAt: Time!
|
||||
}
|
||||
|
||||
type Role {
|
||||
code: String!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type UserAccount {
|
||||
id: ID!
|
||||
email: String!
|
||||
createdAt: Time!
|
||||
fullName: String!
|
||||
initials: String!
|
||||
role: Role!
|
||||
username: String!
|
||||
profileIcon: ProfileIcon!
|
||||
}
|
||||
|
||||
type Team {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
members: [Member!]!
|
||||
}
|
||||
|
||||
type Project {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
team: Team!
|
||||
owner: Member!
|
||||
taskGroups: [TaskGroup!]!
|
||||
members: [Member!]!
|
||||
labels: [ProjectLabel!]!
|
||||
}
|
||||
|
||||
type TaskGroup {
|
||||
id: ID!
|
||||
projectID: String!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
position: Float!
|
||||
tasks: [Task!]!
|
||||
}
|
||||
|
||||
type ChecklistBadge {
|
||||
complete: Int!
|
||||
total: Int!
|
||||
}
|
||||
|
||||
type TaskBadges {
|
||||
checklist: ChecklistBadge
|
||||
}
|
||||
|
||||
type Task {
|
||||
id: ID!
|
||||
taskGroup: TaskGroup!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
position: Float!
|
||||
description: String
|
||||
dueDate: Time
|
||||
complete: Boolean!
|
||||
assigned: [Member!]!
|
||||
labels: [TaskLabel!]!
|
||||
checklists: [TaskChecklist!]!
|
||||
badges: TaskBadges!
|
||||
}
|
||||
|
||||
input ProjectsFilter {
|
||||
teamID: UUID
|
||||
}
|
||||
|
||||
input FindUser {
|
||||
userId: String!
|
||||
}
|
||||
|
||||
input FindProject {
|
||||
projectId: String!
|
||||
}
|
||||
|
||||
input FindTask {
|
||||
taskID: UUID!
|
||||
}
|
||||
|
||||
type Organization {
|
||||
id: ID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
|
||||
input ProjectsFilter {
|
||||
teamID: UUID
|
||||
}
|
||||
|
||||
input FindUser {
|
||||
userId: String!
|
||||
}
|
||||
|
||||
input FindProject {
|
||||
projectId: String!
|
||||
}
|
||||
|
||||
input FindTask {
|
||||
taskID: UUID!
|
||||
}
|
||||
|
||||
type Organization {
|
||||
id: ID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input FindTeam {
|
||||
teamID: UUID!
|
||||
}
|
||||
|
||||
type Query {
|
||||
organizations: [Organization!]!
|
||||
users: [UserAccount!]!
|
||||
findUser(input: FindUser!): UserAccount!
|
||||
findProject(input: FindProject!): Project!
|
||||
findTask(input: FindTask!): Task!
|
||||
projects(input: ProjectsFilter): [Project!]!
|
||||
findTeam(input: FindTeam!): Team!
|
||||
teams: [Team!]!
|
||||
labelColors: [LabelColor!]!
|
||||
taskGroups: [TaskGroup!]!
|
||||
me: UserAccount!
|
||||
}
|
||||
|
||||
type Mutation {}
|
||||
|
||||
extend type Mutation {
|
||||
createTask(input: NewTask!): Task!
|
||||
deleteTask(input: DeleteTaskInput!): DeleteTaskPayload!
|
||||
|
||||
updateTaskDescription(input: UpdateTaskDescriptionInput!): Task!
|
||||
updateTaskLocation(input: NewTaskLocation!): UpdateTaskLocationPayload!
|
||||
updateTaskName(input: UpdateTaskName!): Task!
|
||||
setTaskComplete(input: SetTaskComplete!): Task!
|
||||
updateTaskDueDate(input: UpdateTaskDueDate!): Task!
|
||||
|
||||
assignTask(input: AssignTaskInput): Task!
|
||||
unassignTask(input: UnassignTaskInput): Task!
|
||||
}
|
||||
|
||||
input NewRefreshToken {
|
||||
userId: String!
|
||||
}
|
||||
|
||||
input NewUserAccount {
|
||||
username: String!
|
||||
email: String!
|
||||
fullName: String!
|
||||
initials: String!
|
||||
password: String!
|
||||
roleCode: String!
|
||||
}
|
||||
|
||||
input NewTeam {
|
||||
name: String!
|
||||
organizationID: UUID!
|
||||
}
|
||||
|
||||
input NewProject {
|
||||
userID: UUID!
|
||||
teamID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input NewTaskGroup {
|
||||
projectID: String!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
input LogoutUser {
|
||||
userID: String!
|
||||
}
|
||||
input NewTask {
|
||||
taskGroupID: String!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
input NewTaskLocation {
|
||||
taskID: UUID!
|
||||
taskGroupID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
input DeleteTaskInput {
|
||||
taskID: String!
|
||||
}
|
||||
|
||||
type DeleteTaskPayload {
|
||||
taskID: String!
|
||||
}
|
||||
|
||||
input UpdateTaskName {
|
||||
taskID: String!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input NewTaskGroupLocation {
|
||||
taskGroupID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
input DeleteTaskGroupInput {
|
||||
taskGroupID: UUID!
|
||||
}
|
||||
|
||||
type DeleteTaskGroupPayload {
|
||||
ok: Boolean!
|
||||
affectedRows: Int!
|
||||
taskGroup: TaskGroup!
|
||||
}
|
||||
|
||||
type DeleteTaskChecklistItemPayload {
|
||||
ok: Boolean!
|
||||
taskChecklistItem: TaskChecklistItem!
|
||||
}
|
||||
|
||||
type TaskChecklistItem {
|
||||
id: ID!
|
||||
name: String!
|
||||
taskChecklistID: UUID!
|
||||
complete: Boolean!
|
||||
position: Float!
|
||||
dueDate: Time!
|
||||
}
|
||||
|
||||
type TaskChecklist {
|
||||
id: ID!
|
||||
name: String!
|
||||
position: Float!
|
||||
items: [TaskChecklistItem!]!
|
||||
}
|
||||
|
||||
input AssignTaskInput {
|
||||
taskID: UUID!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
input UnassignTaskInput {
|
||||
taskID: UUID!
|
||||
userID: UUID!
|
||||
}
|
||||
input UpdateTaskDescriptionInput {
|
||||
taskID: UUID!
|
||||
description: String!
|
||||
}
|
||||
|
||||
input AddTaskLabelInput {
|
||||
taskID: UUID!
|
||||
projectLabelID: UUID!
|
||||
}
|
||||
|
||||
input RemoveTaskLabelInput {
|
||||
taskLabelID: UUID!
|
||||
}
|
||||
|
||||
input NewProjectLabel {
|
||||
projectID: UUID!
|
||||
labelColorID: UUID!
|
||||
name: String
|
||||
}
|
||||
|
||||
input DeleteProjectLabel {
|
||||
projectLabelID: UUID!
|
||||
}
|
||||
|
||||
input UpdateProjectLabelName {
|
||||
projectLabelID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input UpdateProjectLabel {
|
||||
projectLabelID: UUID!
|
||||
labelColorID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input UpdateProjectLabelColor {
|
||||
projectLabelID: UUID!
|
||||
labelColorID: UUID!
|
||||
}
|
||||
|
||||
input ToggleTaskLabelInput {
|
||||
taskID: UUID!
|
||||
projectLabelID: UUID!
|
||||
}
|
||||
|
||||
type ToggleTaskLabelPayload {
|
||||
active: Boolean!
|
||||
task: Task!
|
||||
}
|
||||
|
||||
input UpdateProjectName {
|
||||
projectID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type UpdateTaskLocationPayload {
|
||||
previousTaskGroupID: UUID!
|
||||
task: Task!
|
||||
}
|
||||
|
||||
input UpdateTaskGroupName {
|
||||
taskGroupID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input UpdateTaskDueDate {
|
||||
taskID: UUID!
|
||||
dueDate: Time
|
||||
}
|
||||
|
||||
input SetTaskComplete {
|
||||
taskID: UUID!
|
||||
complete: Boolean!
|
||||
}
|
||||
|
||||
input CreateTaskChecklist {
|
||||
taskID: UUID!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
input CreateTaskChecklistItem {
|
||||
taskChecklistID: UUID!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
input SetTaskChecklistItemComplete {
|
||||
taskChecklistItemID: UUID!
|
||||
complete: Boolean!
|
||||
}
|
||||
input DeleteTaskChecklistItem {
|
||||
taskChecklistItemID: UUID!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistItemName {
|
||||
taskChecklistItemID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input CreateTeamMember {
|
||||
userID: UUID!
|
||||
teamID: UUID!
|
||||
}
|
||||
|
||||
type CreateTeamMemberPayload {
|
||||
team: Team!
|
||||
teamMember: Member!
|
||||
}
|
||||
|
||||
input DeleteProject {
|
||||
projectID: UUID!
|
||||
}
|
||||
|
||||
type DeleteProjectPayload {
|
||||
ok: Boolean!
|
||||
project: Project!
|
||||
}
|
||||
|
||||
input DeleteTeam {
|
||||
teamID: UUID!
|
||||
}
|
||||
|
||||
type DeleteTeamPayload {
|
||||
ok: Boolean!
|
||||
team: Team!
|
||||
projects: [Project!]!
|
||||
}
|
||||
|
||||
input DeleteUserAccount {
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
type DeleteUserAccountPayload {
|
||||
ok: Boolean!
|
||||
userAccount: UserAccount!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistName {
|
||||
taskChecklistID: UUID!
|
||||
name: String!
|
||||
}
|
||||
input DeleteTaskChecklist {
|
||||
taskChecklistID: UUID!
|
||||
}
|
||||
type DeleteTaskChecklistPayload {
|
||||
ok: Boolean!
|
||||
taskChecklist: TaskChecklist!
|
||||
}
|
||||
|
||||
input CreateProjectMember {
|
||||
projectID: UUID!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
type CreateProjectMemberPayload {
|
||||
ok: Boolean!
|
||||
member: Member!
|
||||
}
|
||||
|
||||
input DeleteProjectMember {
|
||||
projectID: UUID!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
type DeleteProjectMemberPayload {
|
||||
ok: Boolean!
|
||||
member: Member!
|
||||
projectID: UUID!
|
||||
}
|
||||
|
||||
input UpdateProjectMemberRole {
|
||||
projectID: UUID!
|
||||
userID: UUID!
|
||||
roleCode: RoleCode!
|
||||
}
|
||||
|
||||
type UpdateProjectMemberRolePayload {
|
||||
ok: Boolean!
|
||||
member: Member!
|
||||
}
|
||||
|
||||
input SetProjectOwner {
|
||||
projectID: UUID!
|
||||
ownerID: UUID!
|
||||
}
|
||||
type SetProjectOwnerPayload {
|
||||
ok: Boolean!
|
||||
prevOwner: Member!
|
||||
newOwner: Member!
|
||||
}
|
||||
|
||||
input UpdateTeamMemberRole {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
roleCode: RoleCode!
|
||||
}
|
||||
|
||||
type UpdateTeamMemberRolePayload {
|
||||
ok: Boolean!
|
||||
member: Member!
|
||||
}
|
||||
|
||||
input SetTeamOwner {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
type SetTeamOwnerPayload {
|
||||
ok: Boolean!
|
||||
prevOwner: Member!
|
||||
newOwner: Member!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createRefreshToken(input: NewRefreshToken!): RefreshToken!
|
||||
|
||||
createUserAccount(input: NewUserAccount!): UserAccount!
|
||||
deleteUserAccount(input: DeleteUserAccount!): DeleteUserAccountPayload!
|
||||
|
||||
deleteTeam(input: DeleteTeam!): DeleteTeamPayload!
|
||||
createTeam(input: NewTeam!): Team!
|
||||
clearProfileAvatar: UserAccount!
|
||||
|
||||
createTeamMember(input: CreateTeamMember!): CreateTeamMemberPayload!
|
||||
updateTeamMemberRole(input: UpdateTeamMemberRole!): UpdateTeamMemberRolePayload!
|
||||
setTeamOwner(input: SetTeamOwner!): SetTeamOwnerPayload!
|
||||
|
||||
createProject(input: NewProject!): Project!
|
||||
deleteProject(input: DeleteProject!): DeleteProjectPayload!
|
||||
updateProjectName(input: UpdateProjectName): Project!
|
||||
createProjectMember(input: CreateProjectMember!): CreateProjectMemberPayload!
|
||||
deleteProjectMember(input: DeleteProjectMember!): DeleteProjectMemberPayload!
|
||||
updateProjectMemberRole(input: UpdateProjectMemberRole!): UpdateProjectMemberRolePayload!
|
||||
setProjectOwner(input: SetProjectOwner!): SetProjectOwnerPayload!
|
||||
|
||||
createProjectLabel(input: NewProjectLabel!): ProjectLabel!
|
||||
deleteProjectLabel(input: DeleteProjectLabel!): ProjectLabel!
|
||||
updateProjectLabel(input: UpdateProjectLabel!): ProjectLabel!
|
||||
updateProjectLabelName(input: UpdateProjectLabelName!): ProjectLabel!
|
||||
updateProjectLabelColor(input: UpdateProjectLabelColor!): ProjectLabel!
|
||||
|
||||
createTaskGroup(input: NewTaskGroup!): TaskGroup!
|
||||
updateTaskGroupLocation(input: NewTaskGroupLocation!): TaskGroup!
|
||||
updateTaskGroupName(input: UpdateTaskGroupName!): TaskGroup!
|
||||
deleteTaskGroup(input: DeleteTaskGroupInput!): DeleteTaskGroupPayload!
|
||||
|
||||
addTaskLabel(input: AddTaskLabelInput): Task!
|
||||
removeTaskLabel(input: RemoveTaskLabelInput): Task!
|
||||
toggleTaskLabel(input: ToggleTaskLabelInput!): ToggleTaskLabelPayload!
|
||||
|
||||
createTaskChecklist(input: CreateTaskChecklist!): TaskChecklist!
|
||||
deleteTaskChecklist(input: DeleteTaskChecklist!): DeleteTaskChecklistPayload!
|
||||
updateTaskChecklistName(input: UpdateTaskChecklistName!): TaskChecklist!
|
||||
createTaskChecklistItem(input: CreateTaskChecklistItem!): TaskChecklistItem!
|
||||
updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): TaskChecklistItem!
|
||||
setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): TaskChecklistItem!
|
||||
deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): DeleteTaskChecklistItemPayload!
|
||||
|
||||
logoutUser(input: LogoutUser!): Boolean!
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@ -1330,9 +1330,7 @@ func (r *Resolver) Task() TaskResolver { return &taskResolver{r} }
|
||||
func (r *Resolver) TaskChecklist() TaskChecklistResolver { return &taskChecklistResolver{r} }
|
||||
|
||||
// TaskChecklistItem returns TaskChecklistItemResolver implementation.
|
||||
func (r *Resolver) TaskChecklistItem() TaskChecklistItemResolver {
|
||||
return &taskChecklistItemResolver{r}
|
||||
}
|
||||
func (r *Resolver) TaskChecklistItem() TaskChecklistItemResolver { return &taskChecklistItemResolver{r} }
|
||||
|
||||
// TaskGroup returns TaskGroupResolver implementation.
|
||||
func (r *Resolver) TaskGroup() TaskGroupResolver { return &taskGroupResolver{r} }
|
||||
|
@ -8,13 +8,13 @@ import (
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/project-citadel/internal/auth"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var jwtKey = []byte("citadel_test_key")
|
||||
var jwtKey = []byte("taskcafe_test_key")
|
||||
|
||||
type authResource struct{}
|
||||
|
||||
@ -53,7 +53,7 @@ type AvatarUploadResponseData struct {
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
func (h *CitadelHandler) RefreshTokenHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) RefreshTokenHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
_, err := h.repo.GetSystemOptionByKey(r.Context(), "is_installed")
|
||||
if err == sql.ErrNoRows {
|
||||
@ -124,7 +124,7 @@ func (h *CitadelHandler) RefreshTokenHandler(w http.ResponseWriter, r *http.Requ
|
||||
json.NewEncoder(w).Encode(LoginResponseData{AccessToken: accessTokenString, IsInstalled: true})
|
||||
}
|
||||
|
||||
func (h *CitadelHandler) LogoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) LogoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||
c, err := r.Cookie("refreshToken")
|
||||
if err != nil {
|
||||
if err == http.ErrNoCookie {
|
||||
@ -143,7 +143,7 @@ func (h *CitadelHandler) LogoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(LogoutResponseData{Status: "success"})
|
||||
}
|
||||
|
||||
func (h *CitadelHandler) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var requestData LoginRequestData
|
||||
err := json.NewDecoder(r.Body).Decode(&requestData)
|
||||
if err != nil {
|
||||
@ -190,7 +190,7 @@ func (h *CitadelHandler) LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(LoginResponseData{accessTokenString, false})
|
||||
}
|
||||
|
||||
func (h *CitadelHandler) InstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) InstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if restricted, ok := r.Context().Value("restricted_mode").(auth.RestrictedMode); ok {
|
||||
if restricted != auth.InstallOnly {
|
||||
log.Warning("attempted to install without install only restriction")
|
||||
@ -250,10 +250,10 @@ func (h *CitadelHandler) InstallHandler(w http.ResponseWriter, r *http.Request)
|
||||
json.NewEncoder(w).Encode(LoginResponseData{accessTokenString, false})
|
||||
}
|
||||
|
||||
func (rs authResource) Routes(citadelHandler CitadelHandler) chi.Router {
|
||||
func (rs authResource) Routes(taskcafeHandler TaskcafeHandler) chi.Router {
|
||||
r := chi.NewRouter()
|
||||
r.Post("/login", citadelHandler.LoginHandler)
|
||||
r.Post("/refresh_token", citadelHandler.RefreshTokenHandler)
|
||||
r.Post("/logout", citadelHandler.LogoutHandler)
|
||||
r.Post("/login", taskcafeHandler.LoginHandler)
|
||||
r.Post("/refresh_token", taskcafeHandler.RefreshTokenHandler)
|
||||
r.Post("/logout", taskcafeHandler.LogoutHandler)
|
||||
return r
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import (
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/project-citadel/internal/frontend"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/frontend"
|
||||
)
|
||||
|
||||
func (h *CitadelHandler) Frontend(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) Frontend(w http.ResponseWriter, r *http.Request) {
|
||||
f, err := frontend.Frontend.Open("index.h")
|
||||
if os.IsNotExist(err) {
|
||||
log.Warning("does not exist")
|
||||
@ -26,7 +26,7 @@ func (h *CitadelHandler) Frontend(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeContent(w, r, "index.html", time.Now(), f)
|
||||
}
|
||||
|
||||
func (h *CitadelHandler) ProfileImageUpload(w http.ResponseWriter, r *http.Request) {
|
||||
func (h *TaskcafeHandler) ProfileImageUpload(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("preparing to upload file")
|
||||
userID, ok := r.Context().Value("userID").(uuid.UUID)
|
||||
if !ok {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/project-citadel/internal/auth"
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -10,11 +10,11 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/jordanknott/project-citadel/internal/config"
|
||||
"github.com/jordanknott/project-citadel/internal/db"
|
||||
"github.com/jordanknott/project-citadel/internal/frontend"
|
||||
"github.com/jordanknott/project-citadel/internal/graph"
|
||||
"github.com/jordanknott/project-citadel/internal/logger"
|
||||
"github.com/jordanknott/taskcafe/internal/config"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/frontend"
|
||||
"github.com/jordanknott/taskcafe/internal/graph"
|
||||
"github.com/jordanknott/taskcafe/internal/logger"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@ -59,7 +59,7 @@ func (h FrontendHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeContent(w, r, path, time.Now(), f)
|
||||
}
|
||||
|
||||
type CitadelHandler struct {
|
||||
type TaskcafeHandler struct {
|
||||
config config.AppConfig
|
||||
repo db.Repository
|
||||
}
|
||||
@ -92,19 +92,19 @@ func NewRouter(config config.AppConfig, dbConnection *sqlx.DB) (chi.Router, erro
|
||||
r.Use(middleware.Timeout(60 * time.Second))
|
||||
|
||||
repository := db.NewRepository(dbConnection)
|
||||
citadelHandler := CitadelHandler{config, *repository}
|
||||
taskcafeHandler := TaskcafeHandler{config, *repository}
|
||||
|
||||
var imgServer = http.FileServer(http.Dir("./uploads/"))
|
||||
r.Group(func(mux chi.Router) {
|
||||
mux.Mount("/auth", authResource{}.Routes(citadelHandler))
|
||||
mux.Mount("/auth", authResource{}.Routes(taskcafeHandler))
|
||||
mux.Handle("/__graphql", graph.NewPlaygroundHandler("/graphql"))
|
||||
mux.Mount("/uploads/", http.StripPrefix("/uploads/", imgServer))
|
||||
|
||||
})
|
||||
r.Group(func(mux chi.Router) {
|
||||
mux.Use(AuthenticationMiddleware)
|
||||
mux.Post("/users/me/avatar", citadelHandler.ProfileImageUpload)
|
||||
mux.Post("/auth/install", citadelHandler.InstallHandler)
|
||||
mux.Post("/users/me/avatar", taskcafeHandler.ProfileImageUpload)
|
||||
mux.Post("/auth/install", taskcafeHandler.InstallHandler)
|
||||
mux.Handle("/graphql", graph.NewHandler(config, *repository))
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user