summaryrefslogtreecommitdiff
blob: 5f1f579dd5e9c4f4fba9596cfc31ea948b7fdca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Used to show the landing page of the application

package admin

import (
	"glsamaker/pkg/app/handler/authentication"
	"glsamaker/pkg/app/handler/authentication/utils"
	"glsamaker/pkg/database/connection"
	"glsamaker/pkg/models/users"
	"net/http"
)

// Show renders a template to show the landing page of the application
func Show(w http.ResponseWriter, r *http.Request) {

	user := utils.GetAuthenticatedUser(r)

	if !user.Permissions.Admin.View {
		authentication.AccessDenied(w, r)
		return
	}

	var users []*users.User
	connection.DB.Model(&users).Order("email ASC").Select()

	renderAdminTemplate(w, user, users)
}