Commit 35242354 authored by Lee Brown's avatar Lee Brown

issue #28 - renamed project to checklist

parent 0027bef3
......@@ -220,7 +220,7 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "List projects",
"parameters": [
......@@ -261,7 +261,7 @@ var doc = `{
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/project.ProjectResponse"
"$ref": "#/definitions/checklist.ProjectResponse"
}
}
},
......@@ -291,7 +291,7 @@ var doc = `{
"OAuth2Password": []
}
],
"description": "Create inserts a new project into the system.",
"description": "Create inserts a new checklist into the system.",
"consumes": [
"application/json"
],
......@@ -299,9 +299,9 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "Create new project.",
"summary": "Create new checklist.",
"parameters": [
{
"description": "Project details",
......@@ -310,7 +310,7 @@ var doc = `{
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/project.ProjectCreateRequest"
"$ref": "#/definitions/checklist.ProjectCreateRequest"
}
}
],
......@@ -318,7 +318,7 @@ var doc = `{
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/project.ProjectResponse"
"$ref": "#/definitions/checklist.ProjectResponse"
}
},
"400": {
......@@ -353,7 +353,7 @@ var doc = `{
"OAuth2Password": []
}
],
"description": "Update updates the specified project in the system.",
"description": "Update updates the specified checklist in the system.",
"consumes": [
"application/json"
],
......@@ -361,9 +361,9 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "Update project by ID",
"summary": "Update checklist by ID",
"parameters": [
{
"description": "Update fields",
......@@ -372,7 +372,7 @@ var doc = `{
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/project.ProjectUpdateRequest"
"$ref": "#/definitions/checklist.ProjectUpdateRequest"
}
}
],
......@@ -406,7 +406,7 @@ var doc = `{
"OAuth2Password": []
}
],
"description": "Archive soft-deletes the specified project from the system.",
"description": "Archive soft-deletes the specified checklist from the system.",
"consumes": [
"application/json"
],
......@@ -414,9 +414,9 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "Archive project by ID",
"summary": "Archive checklist by ID",
"parameters": [
{
"description": "Update fields",
......@@ -425,7 +425,7 @@ var doc = `{
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/project.ProjectArchiveRequest"
"$ref": "#/definitions/checklist.ProjectArchiveRequest"
}
}
],
......@@ -459,7 +459,7 @@ var doc = `{
"OAuth2Password": []
}
],
"description": "Read returns the specified project from the system.",
"description": "Read returns the specified checklist from the system.",
"consumes": [
"application/json"
],
......@@ -467,9 +467,9 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "Get project by ID.",
"summary": "Get checklist by ID.",
"parameters": [
{
"type": "string",
......@@ -483,7 +483,7 @@ var doc = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/project.ProjectResponse"
"$ref": "#/definitions/checklist.ProjectResponse"
}
},
"400": {
......@@ -512,7 +512,7 @@ var doc = `{
"OAuth2Password": []
}
],
"description": "Delete removes the specified project from the system.",
"description": "Delete removes the specified checklist from the system.",
"consumes": [
"application/json"
],
......@@ -520,9 +520,9 @@ var doc = `{
"application/json"
],
"tags": [
"project"
"checklist"
],
"summary": "Delete project by ID",
"summary": "Delete checklist by ID",
"parameters": [
{
"type": "string",
......@@ -1512,7 +1512,7 @@ var doc = `{
}
}
},
"project.ProjectArchiveRequest": {
"checklist.ProjectArchiveRequest": {
"type": "object",
"required": [
"id"
......@@ -1524,7 +1524,7 @@ var doc = `{
}
}
},
"project.ProjectCreateRequest": {
"checklist.ProjectCreateRequest": {
"type": "object",
"required": [
"account_id",
......@@ -1541,7 +1541,7 @@ var doc = `{
}
}
},
"project.ProjectResponse": {
"checklist.ProjectResponse": {
"type": "object",
"required": [
"account_id",
......@@ -1579,7 +1579,7 @@ var doc = `{
}
}
},
"project.ProjectUpdateRequest": {
"checklist.ProjectUpdateRequest": {
"type": "object",
"required": [
"id"
......
......@@ -673,7 +673,7 @@ paths:
description: OK
schema:
items:
$ref: '#/definitions/project.ProjectResponse'
$ref: '#/definitions/checklist.ProjectResponse'
type: array
"400":
description: Bad Request
......@@ -691,18 +691,18 @@ paths:
- OAuth2Password: []
summary: List projects
tags:
- project
- checklist
patch:
consumes:
- application/json
description: Update updates the specified project in the system.
description: Update updates the specified checklist in the system.
parameters:
- description: Update fields
in: body
name: data
required: true
schema:
$ref: '#/definitions/project.ProjectUpdateRequest'
$ref: '#/definitions/checklist.ProjectUpdateRequest'
type: object
produces:
- application/json
......@@ -722,20 +722,20 @@ paths:
$ref: '#/definitions/weberror.ErrorResponse'
security:
- OAuth2Password: []
summary: Update project by ID
summary: Update checklist by ID
tags:
- project
- checklist
post:
consumes:
- application/json
description: Create inserts a new project into the system.
description: Create inserts a new checklist into the system.
parameters:
- description: Project details
in: body
name: data
required: true
schema:
$ref: '#/definitions/project.ProjectCreateRequest'
$ref: '#/definitions/checklist.ProjectCreateRequest'
type: object
produces:
- application/json
......@@ -743,7 +743,7 @@ paths:
"201":
description: Created
schema:
$ref: '#/definitions/project.ProjectResponse'
$ref: '#/definitions/checklist.ProjectResponse'
"400":
description: Bad Request
schema:
......@@ -762,14 +762,14 @@ paths:
$ref: '#/definitions/weberror.ErrorResponse'
security:
- OAuth2Password: []
summary: Create new project.
summary: Create new checklist.
tags:
- project
- checklist
/projects/{id}:
delete:
consumes:
- application/json
description: Delete removes the specified project from the system.
description: Delete removes the specified checklist from the system.
parameters:
- description: Project ID
in: path
......@@ -794,13 +794,13 @@ paths:
$ref: '#/definitions/weberror.ErrorResponse'
security:
- OAuth2Password: []
summary: Delete project by ID
summary: Delete checklist by ID
tags:
- project
- checklist
get:
consumes:
- application/json
description: Read returns the specified project from the system.
description: Read returns the specified checklist from the system.
parameters:
- description: Project ID
in: path
......@@ -813,7 +813,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/project.ProjectResponse'
$ref: '#/definitions/checklist.ProjectResponse'
"400":
description: Bad Request
schema:
......@@ -828,21 +828,21 @@ paths:
$ref: '#/definitions/weberror.ErrorResponse'
security:
- OAuth2Password: []
summary: Get project by ID.
summary: Get checklist by ID.
tags:
- project
- checklist
/projects/archive:
patch:
consumes:
- application/json
description: Archive soft-deletes the specified project from the system.
description: Archive soft-deletes the specified checklist from the system.
parameters:
- description: Update fields
in: body
name: data
required: true
schema:
$ref: '#/definitions/project.ProjectArchiveRequest'
$ref: '#/definitions/checklist.ProjectArchiveRequest'
type: object
produces:
- application/json
......@@ -862,9 +862,9 @@ paths:
$ref: '#/definitions/weberror.ErrorResponse'
security:
- OAuth2Password: []
summary: Archive project by ID
summary: Archive checklist by ID
tags:
- project
- checklist
/signup:
post:
consumes:
......
......@@ -4,18 +4,18 @@ import (
"context"
"net/http"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"github.com/pkg/errors"
)
// Example represents the Example API method handler set.
type Example struct {
Project *project.Repository
Checklist *checklist.Repository
// ADD OTHER STATE LIKE THE LOGGER AND CONFIG HERE.
}
......@@ -28,7 +28,7 @@ func (h *Example) ErrorResponse(ctx context.Context, w http.ResponseWriter, r *h
}
if qv := r.URL.Query().Get("test-validation-error"); qv != "" {
_, err := h.Project.Create(ctx, auth.Claims{}, project.ProjectCreateRequest{}, v.Now)
_, err := h.Checklist.Create(ctx, auth.Claims{}, checklist.ChecklistCreateRequest{}, v.Now)
return web.RespondJsonError(ctx, w, err)
}
......
......@@ -7,13 +7,13 @@ import (
"geeks-accelerator/oss/saas-starter-kit/internal/account"
"geeks-accelerator/oss/saas-starter-kit/internal/account/account_preference"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
saasSwagger "geeks-accelerator/oss/saas-starter-kit/internal/mid/saas-swagger"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
_ "geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"geeks-accelerator/oss/saas-starter-kit/internal/signup"
"geeks-accelerator/oss/saas-starter-kit/internal/user"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
......@@ -36,7 +36,7 @@ type AppContext struct {
AuthRepo *user_auth.Repository
SignupRepo *signup.Repository
InviteRepo *invite.Repository
ProjectRepo *project.Repository
ChecklistRepo *checklist.Repository
Authenticator *auth.Authenticator
PreAppMiddleware []web.Middleware
PostAppMiddleware []web.Middleware
......@@ -74,7 +74,7 @@ func API(shutdown chan os.Signal, appCtx *AppContext) http.Handler {
// Register example endpoints.
ex := Example{
Project: appCtx.ProjectRepo,
Checklist: appCtx.ChecklistRepo,
}
app.Handle("GET", "/v1/examples/error-response", ex.ErrorResponse)
......@@ -119,16 +119,16 @@ func API(shutdown chan os.Signal, appCtx *AppContext) http.Handler {
}
app.Handle("POST", "/v1/signup", s.Signup)
// Register project.
p := Projects{
Repository: appCtx.ProjectRepo,
// Register checklist.
p := Checklists{
Repository: appCtx.ChecklistRepo,
}
app.Handle("GET", "/v1/projects", p.Find, mid.AuthenticateHeader(appCtx.Authenticator))
app.Handle("POST", "/v1/projects", p.Create, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/v1/projects/:id", p.Read, mid.AuthenticateHeader(appCtx.Authenticator))
app.Handle("PATCH", "/v1/projects", p.Update, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("PATCH", "/v1/projects/archive", p.Archive, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("DELETE", "/v1/projects/:id", p.Delete, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/v1/checklists", p.Find, mid.AuthenticateHeader(appCtx.Authenticator))
app.Handle("POST", "/v1/checklists", p.Create, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/v1/checklists/:id", p.Read, mid.AuthenticateHeader(appCtx.Authenticator))
app.Handle("PATCH", "/v1/checklists", p.Update, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("PATCH", "/v1/checklists/archive", p.Archive, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("DELETE", "/v1/checklists/:id", p.Delete, mid.AuthenticateHeader(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
// Register swagger documentation.
// TODO: Add authentication. Current authenticator requires an Authorization header
......
......@@ -22,18 +22,18 @@ import (
"geeks-accelerator/oss/saas-starter-kit/cmd/web-api/handlers"
"geeks-accelerator/oss/saas-starter-kit/internal/account"
"geeks-accelerator/oss/saas-starter-kit/internal/account/account_preference"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/flag"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/notify"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"geeks-accelerator/oss/saas-starter-kit/internal/signup"
"geeks-accelerator/oss/saas-starter-kit/internal/user"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account/invite"
"geeks-accelerator/oss/saas-starter-kit/internal/user_auth"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
......@@ -437,19 +437,19 @@ func main() {
// =========================================================================
// Init repositories and AppContext
projectRoute, err := webroute.New(cfg.Service.BaseUrl, cfg.Project.WebAppBaseUrl)
webRoute, err := webroute.New(cfg.Service.BaseUrl, cfg.Project.WebAppBaseUrl)
if err != nil {
log.Fatalf("main : project routes : %s: %+v", cfg.Service.BaseUrl, err)
log.Fatalf("main : checklist routes : %s: %+v", cfg.Service.BaseUrl, err)
}
usrRepo := user.NewRepository(masterDb, projectRoute.UserResetPassword, notifyEmail, cfg.Project.SharedSecretKey)
usrRepo := user.NewRepository(masterDb, webRoute.UserResetPassword, notifyEmail, cfg.Project.SharedSecretKey)
usrAccRepo := user_account.NewRepository(masterDb)
accRepo := account.NewRepository(masterDb)
accPrefRepo := account_preference.NewRepository(masterDb)
authRepo := user_auth.NewRepository(masterDb, authenticator, usrRepo, usrAccRepo, accPrefRepo)
signupRepo := signup.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo)
inviteRepo := invite.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo, projectRoute.UserInviteAccept, notifyEmail, cfg.Project.SharedSecretKey)
prjRepo := project.NewRepository(masterDb)
inviteRepo := invite.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo, webRoute.UserInviteAccept, notifyEmail, cfg.Project.SharedSecretKey)
chklstRepo := checklist.NewRepository(masterDb)
appCtx := &handlers.AppContext{
Log: log,
......@@ -463,7 +463,7 @@ func main() {
AuthRepo: authRepo,
SignupRepo: signupRepo,
InviteRepo: inviteRepo,
ProjectRepo: prjRepo,
ChecklistRepo: chklstRepo,
Authenticator: authenticator,
}
......
......@@ -17,19 +17,19 @@ import (
"geeks-accelerator/oss/saas-starter-kit/cmd/web-api/handlers"
"geeks-accelerator/oss/saas-starter-kit/internal/account"
"geeks-accelerator/oss/saas-starter-kit/internal/account/account_preference"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/notify"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/tests"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"geeks-accelerator/oss/saas-starter-kit/internal/signup"
"geeks-accelerator/oss/saas-starter-kit/internal/user"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account/invite"
"geeks-accelerator/oss/saas-starter-kit/internal/user_auth"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"github.com/google/go-cmp/cmp"
"github.com/iancoleman/strcase"
"github.com/pborman/uuid"
......@@ -107,7 +107,7 @@ func testMain(m *testing.M) int {
authRepo := user_auth.NewRepository(test.MasterDB, authenticator, usrRepo, usrAccRepo, accPrefRepo)
signupRepo := signup.NewRepository(test.MasterDB, usrRepo, usrAccRepo, accRepo)
inviteRepo := invite.NewRepository(test.MasterDB, usrRepo, usrAccRepo, accRepo, projectRoute.UserInviteAccept, notifyEmail, "6368616e676520746869732070613434")
prjRepo := project.NewRepository(test.MasterDB)
prjRepo := checklist.NewRepository(test.MasterDB)
appCtx = &handlers.AppContext{
Log: log,
......
......@@ -19,9 +19,9 @@ import (
// Root represents the Root API method handler set.
type Root struct {
Renderer web.Renderer
Sitemap *stm.Sitemap
ProjectRoute webroute.ProjectRoute
Renderer web.Renderer
Sitemap *stm.Sitemap
WebRoute webroute.WebRoute
}
// Index determines if the user has authentication and loads the associated page.
......@@ -56,7 +56,7 @@ func (h *Root) SitePage(ctx context.Context, w http.ResponseWriter, r *http.Requ
tmpName = "site-api.gohtml"
// http://127.0.0.1:3001/docs/doc.json
swaggerJsonUrl := h.ProjectRoute.ApiDocsJson(true)
swaggerJsonUrl := h.WebRoute.ApiDocsJson(true)
// Load the json file from the API service.
res, err := pester.Get(swaggerJsonUrl)
......@@ -92,8 +92,8 @@ func (h *Root) SitePage(ctx context.Context, w http.ResponseWriter, r *http.Requ
return errors.WithStack(err)
}
data["urlApiBaseUri"] = h.ProjectRoute.WebApiUrl(doc.BasePath)
data["urlApiDocs"] = h.ProjectRoute.ApiDocs()
data["urlApiBaseUri"] = h.WebRoute.WebApiUrl(doc.BasePath)
data["urlApiDocs"] = h.WebRoute.ApiDocs()
case "/pricing":
tmpName = "site-pricing.gohtml"
......@@ -122,7 +122,7 @@ func (h *Root) RobotTxt(ctx context.Context, w http.ResponseWriter, r *http.Requ
return web.RespondText(ctx, w, txt, http.StatusOK)
}
sitemapUrl := h.ProjectRoute.WebAppUrl("/sitemap.xml")
sitemapUrl := h.WebRoute.WebAppUrl("/sitemap.xml")
txt := fmt.Sprintf("User-agent: *\nDisallow: /ping\nDisallow: /status\nDisallow: /debug/\nSitemap: %s", sitemapUrl)
return web.RespondText(ctx, w, txt, http.StatusOK)
......
......@@ -11,19 +11,19 @@ import (
"geeks-accelerator/oss/saas-starter-kit/internal/account"
"geeks-accelerator/oss/saas-starter-kit/internal/account/account_preference"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/geonames"
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"geeks-accelerator/oss/saas-starter-kit/internal/signup"
"geeks-accelerator/oss/saas-starter-kit/internal/user"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account/invite"
"geeks-accelerator/oss/saas-starter-kit/internal/user_auth"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/ikeikeikeike/go-sitemap-generator/v2/stm"
......@@ -50,13 +50,13 @@ type AppContext struct {
AuthRepo *user_auth.Repository
SignupRepo *signup.Repository
InviteRepo *invite.Repository
ProjectRepo *project.Repository
ChecklistRepo *checklist.Repository
GeoRepo *geonames.Repository
Authenticator *auth.Authenticator
StaticDir string
TemplateDir string
Renderer web.Renderer
ProjectRoute webroute.ProjectRoute
WebRoute webroute.WebRoute
PreAppMiddleware []web.Middleware
PostAppMiddleware []web.Middleware
AwsSession *session.Session
......@@ -105,7 +105,7 @@ func APP(shutdown chan os.Signal, appCtx *AppContext) http.Handler {
// Build a sitemap.
sm := stm.NewSitemap(1)
sm.SetVerbose(false)
sm.SetDefaultHost(appCtx.ProjectRoute.WebAppUrl(""))
sm.SetDefaultHost(appCtx.WebRoute.WebAppUrl(""))
sm.Create()
smLocAddModified := func(loc stm.URL, filename string) {
......@@ -121,19 +121,19 @@ func APP(shutdown chan os.Signal, appCtx *AppContext) http.Handler {
sm.Add(loc)
}
// Register project management pages.
p := Projects{
ProjectRepo: appCtx.ProjectRepo,
Redis: appCtx.Redis,
Renderer: appCtx.Renderer,
// Register checklist management pages.
p := Checklists{
ChecklistRepo: appCtx.ChecklistRepo,
Redis: appCtx.Redis,
Renderer: appCtx.Renderer,
}
app.Handle("POST", "/projects/:project_id/update", p.Update, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/projects/:project_id/update", p.Update, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("POST", "/projects/:project_id", p.View, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/projects/:project_id", p.View, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasAuth())
app.Handle("POST", "/projects/create", p.Create, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/projects/create", p.Create, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/projects", p.Index, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasAuth())
app.Handle("POST", "/checklists/:checklist_id/update", p.Update, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/checklists/:checklist_id/update", p.Update, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("POST", "/checklists/:checklist_id", p.View, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/checklists/:checklist_id", p.View, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasAuth())
app.Handle("POST", "/checklists/create", p.Create, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/checklists/create", p.Create, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasRole(auth.RoleAdmin))
app.Handle("GET", "/checklists", p.Index, mid.AuthenticateSessionRequired(appCtx.Authenticator), mid.HasAuth())
// Register user management pages.
us := Users{
......@@ -231,9 +231,9 @@ func APP(shutdown chan os.Signal, appCtx *AppContext) http.Handler {
// Register root
r := Root{
Renderer: appCtx.Renderer,
ProjectRoute: appCtx.ProjectRoute,
Sitemap: sm,
Renderer: appCtx.Renderer,
WebRoute: appCtx.WebRoute,
Sitemap: sm,
}
app.Handle("GET", "/api", r.SitePage)
app.Handle("GET", "/pricing", r.SitePage)
......
......@@ -23,6 +23,7 @@ import (
"geeks-accelerator/oss/saas-starter-kit/cmd/web-app/handlers"
"geeks-accelerator/oss/saas-starter-kit/internal/account"
"geeks-accelerator/oss/saas-starter-kit/internal/account/account_preference"
"geeks-accelerator/oss/saas-starter-kit/internal/checklist"
"geeks-accelerator/oss/saas-starter-kit/internal/geonames"
"geeks-accelerator/oss/saas-starter-kit/internal/mid"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/auth"
......@@ -33,13 +34,12 @@ import (
template_renderer "geeks-accelerator/oss/saas-starter-kit/internal/platform/web/tmplrender"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/weberror"
"geeks-accelerator/oss/saas-starter-kit/internal/project"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"geeks-accelerator/oss/saas-starter-kit/internal/signup"
"geeks-accelerator/oss/saas-starter-kit/internal/user"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
"geeks-accelerator/oss/saas-starter-kit/internal/user_account/invite"
"geeks-accelerator/oss/saas-starter-kit/internal/user_auth"
"geeks-accelerator/oss/saas-starter-kit/internal/webroute"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
......@@ -440,20 +440,20 @@ func main() {
// =========================================================================
// Init repositories and AppContext
projectRoute, err := webroute.New(cfg.Project.WebApiBaseUrl, cfg.Service.BaseUrl)
webRoute, err := webroute.New(cfg.Project.WebApiBaseUrl, cfg.Service.BaseUrl)
if err != nil {
log.Fatalf("main : project routes : %+v", cfg.Service.BaseUrl, err)
log.Fatalf("main : checklist routes : %+v", cfg.Service.BaseUrl, err)
}
usrRepo := user.NewRepository(masterDb, projectRoute.UserResetPassword, notifyEmail, cfg.Project.SharedSecretKey)
usrRepo := user.NewRepository(masterDb, webRoute.UserResetPassword, notifyEmail, cfg.Project.SharedSecretKey)
usrAccRepo := user_account.NewRepository(masterDb)
accRepo := account.NewRepository(masterDb)
geoRepo := geonames.NewRepository(masterDb)
accPrefRepo := account_preference.NewRepository(masterDb)
authRepo := user_auth.NewRepository(masterDb, authenticator, usrRepo, usrAccRepo, accPrefRepo)
signupRepo := signup.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo)
inviteRepo := invite.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo, projectRoute.UserInviteAccept, notifyEmail, cfg.Project.SharedSecretKey)
prjRepo := project.NewRepository(masterDb)
inviteRepo := invite.NewRepository(masterDb, usrRepo, usrAccRepo, accRepo, webRoute.UserInviteAccept, notifyEmail, cfg.Project.SharedSecretKey)
chklstRepo := checklist.NewRepository(masterDb)
appCtx := &handlers.AppContext{
Log: log,
......@@ -463,7 +463,7 @@ func main() {
Redis: redisClient,
TemplateDir: cfg.Service.TemplateDir,
StaticDir: cfg.Service.StaticFiles.Dir,
ProjectRoute: projectRoute,
WebRoute: webRoute,
UserRepo: usrRepo,
UserAccountRepo: usrAccRepo,
AccountRepo: accRepo,
......@@ -472,7 +472,7 @@ func main() {
GeoRepo: geoRepo,
SignupRepo: signupRepo,
InviteRepo: inviteRepo,
ProjectRepo: prjRepo,
ChecklistRepo: chklstRepo,
Authenticator: authenticator,
AwsSession: awsSession,
}
......@@ -525,13 +525,14 @@ func main() {
staticS3UrlFormatter = func(p string) string {
// When the path starts with a forward slash its referencing a local file,
// make sure the static file prefix is included
if strings.HasPrefix(p, "/") || !strings.HasPrefix(p, "://") {
if (strings.HasPrefix(p, "/") || !strings.HasPrefix(p, "://")) && !strings.HasPrefix(p, cfg.Service.StaticFiles.S3Prefix) {
p = filepath.Join(cfg.Service.StaticFiles.S3Prefix, p)
}
return s3UrlFormatter(p)
}
} else {