Browse Source

Time to get back to work - starting with some simple comment fixes.

pull/24/head
unknown 6 years ago
parent
commit
d567153d2a
2 changed files with 9 additions and 4 deletions
  1. +7
    -2
      controllers/route.go
  2. +2
    -2
      templates/login.html

+ 7
- 2
controllers/route.go View File

@ -28,7 +28,6 @@ func CreateAdminRouter() http.Handler {
router.HandleFunc("/register", Register)
router.HandleFunc("/", Use(Base, mid.RequireLogin))
router.HandleFunc("/settings", Use(Settings, mid.RequireLogin))
// Create the API routes
api := router.PathPrefix("/api").Subrouter()
api = api.StrictSlash(true)
@ -56,7 +55,7 @@ func CreateAdminRouter() http.Handler {
return Use(csrfHandler.ServeHTTP, mid.GetContext)
}
//CreateEndpointRouter creates the router that handles phishing connections.
// CreatePhishingRouter creates the router that handles phishing connections.
func CreatePhishingRouter() http.Handler {
router := mux.NewRouter()
router.PathPrefix("/static").Handler(http.FileServer(http.Dir("./static/endpoint/")))
@ -96,6 +95,7 @@ func Use(handler http.HandlerFunc, mid ...func(http.Handler) http.HandlerFunc) h
return handler
}
// Register creates a new user
func Register(w http.ResponseWriter, r *http.Request) {
// If it is a post request, attempt to register the account
// Now that we are all registered, we can log the user in
@ -142,6 +142,7 @@ func Register(w http.ResponseWriter, r *http.Request) {
}
}
// Logout destroys the current user session
func Logout(w http.ResponseWriter, r *http.Request) {
// If it is a post request, attempt to register the account
// Now that we are all registered, we can log the user in
@ -151,6 +152,7 @@ func Logout(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "login", 302)
}
// Base handles the default path and template execution
func Base(w http.ResponseWriter, r *http.Request) {
// Example of using session - will be removed.
params := struct {
@ -162,6 +164,7 @@ func Base(w http.ResponseWriter, r *http.Request) {
getTemplate(w, "dashboard").ExecuteTemplate(w, "base", params)
}
// Settings handles the changing of settings
func Settings(w http.ResponseWriter, r *http.Request) {
switch {
case r.Method == "POST":
@ -178,6 +181,8 @@ func Settings(w http.ResponseWriter, r *http.Request) {
}
}
// Login handles the authentication flow for a user. If credentials are valid,
// a session is created
func Login(w http.ResponseWriter, r *http.Request) {
params := struct {
User models.User

+ 2
- 2
templates/login.html View File

@ -54,7 +54,7 @@
{{%template "flashes" .Flashes%}}
<input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
<input type="hidden" name="csrf_token" value="{{%.Token%}}"/>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div>
@ -67,4 +67,4 @@
</body>
</html>
{{% end %}}
{{% end %}}

Loading…
Cancel
Save