mirror of https://github.com/gophish/gophish
Time to get back to work - starting with some simple comment fixes.
parent
33b9ec2196
commit
d567153d2a
|
@ -28,7 +28,6 @@ func CreateAdminRouter() http.Handler {
|
||||||
router.HandleFunc("/register", Register)
|
router.HandleFunc("/register", Register)
|
||||||
router.HandleFunc("/", Use(Base, mid.RequireLogin))
|
router.HandleFunc("/", Use(Base, mid.RequireLogin))
|
||||||
router.HandleFunc("/settings", Use(Settings, mid.RequireLogin))
|
router.HandleFunc("/settings", Use(Settings, mid.RequireLogin))
|
||||||
|
|
||||||
// Create the API routes
|
// Create the API routes
|
||||||
api := router.PathPrefix("/api").Subrouter()
|
api := router.PathPrefix("/api").Subrouter()
|
||||||
api = api.StrictSlash(true)
|
api = api.StrictSlash(true)
|
||||||
|
@ -56,7 +55,7 @@ func CreateAdminRouter() http.Handler {
|
||||||
return Use(csrfHandler.ServeHTTP, mid.GetContext)
|
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 {
|
func CreatePhishingRouter() http.Handler {
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.PathPrefix("/static").Handler(http.FileServer(http.Dir("./static/endpoint/")))
|
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
|
return handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register creates a new user
|
||||||
func Register(w http.ResponseWriter, r *http.Request) {
|
func Register(w http.ResponseWriter, r *http.Request) {
|
||||||
// If it is a post request, attempt to register the account
|
// If it is a post request, attempt to register the account
|
||||||
// Now that we are all registered, we can log the user in
|
// 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) {
|
func Logout(w http.ResponseWriter, r *http.Request) {
|
||||||
// If it is a post request, attempt to register the account
|
// If it is a post request, attempt to register the account
|
||||||
// Now that we are all registered, we can log the user in
|
// 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)
|
http.Redirect(w, r, "login", 302)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Base handles the default path and template execution
|
||||||
func Base(w http.ResponseWriter, r *http.Request) {
|
func Base(w http.ResponseWriter, r *http.Request) {
|
||||||
// Example of using session - will be removed.
|
// Example of using session - will be removed.
|
||||||
params := struct {
|
params := struct {
|
||||||
|
@ -162,6 +164,7 @@ func Base(w http.ResponseWriter, r *http.Request) {
|
||||||
getTemplate(w, "dashboard").ExecuteTemplate(w, "base", params)
|
getTemplate(w, "dashboard").ExecuteTemplate(w, "base", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings handles the changing of settings
|
||||||
func Settings(w http.ResponseWriter, r *http.Request) {
|
func Settings(w http.ResponseWriter, r *http.Request) {
|
||||||
switch {
|
switch {
|
||||||
case r.Method == "POST":
|
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) {
|
func Login(w http.ResponseWriter, r *http.Request) {
|
||||||
params := struct {
|
params := struct {
|
||||||
User models.User
|
User models.User
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
{{%template "flashes" .Flashes%}}
|
{{%template "flashes" .Flashes%}}
|
||||||
<input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
|
<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="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>
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue