Migrated settings (at least it loads).

Working on making the template syntax consistent across all the files, cleaning them up, etc.
pull/24/head
unknown 2015-06-21 16:10:47 -05:00
parent 1cf017acba
commit 0e496bdf73
5 changed files with 91 additions and 72 deletions

View File

@ -182,7 +182,6 @@ func Register(w http.ResponseWriter, r *http.Request) {
// 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 {
User models.User
Title string
@ -255,6 +254,14 @@ func LandingPages(w http.ResponseWriter, r *http.Request) {
// Settings handles the changing of settings
func Settings(w http.ResponseWriter, r *http.Request) {
switch {
case r.Method == "GET":
params := struct {
User models.User
Title string
Flashes []interface{}
Token string
}{Title: "Dashboard", User: ctx.Get(r, "user").(models.User), Token: nosurf.Token(r)}
getTemplate(w, "settings").ExecuteTemplate(w, "base", params)
case r.Method == "POST":
err := auth.ChangePassword(r)
msg := models.Response{Success: true, Message: "Settings Updated Successfully"}

View File

@ -78,3 +78,6 @@
</div>
</div>
{{end}}
{{define "scripts"}}
<script src="/js/app/campaigns.js"></script>
{{end}}

View File

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Gophish - Open-Source Phishing Toolkit">
<meta name="author" content="Jordan Wright (http://github.com/jordan-wright)">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<link rel="shortcut icon" href="/favicon.png">
<title>Gophish - {{ .Title }}</title>
@ -54,15 +54,13 @@
{{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">Register</button>
</form>
</div>
<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.js"></script>
<script src="/js/ui-bootstrap-0.10.0.min.js"></script>
</body>

View File

@ -1,66 +1,70 @@
{{define "body"}}
<div class="jumbotron">
<div class="container" style="text-align:center;">
<h1 class="sans header">
Settings
</h1>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li><a href="/">Dashboard</a>
</li>
<li><a href="/campaigns">Campaigns</a>
</li>
<li><a href="/users">Users &amp; Groups</a>
</li>
<li><a href="/templates">Email Templates</a>
</li>
<li><a href="/landing_pages">Landing Pages</a>
</li>
<li class="active"><a href="/settings">Settings</a>
</li>
<li><a href="/api/">API Documentation</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3 sidebar">
<ul class="nav nav-pills nav-stacked">
<li><a href="/">Dashboard</a>
</li>
<li><a href="/users">Users &amp; Groups</a>
</li>
<li><a href="/templates">Templates</a>
</li>
<li class="active"><a href="/settings">Settings</a>
</li>
<li><a href="/api/">API Documentation</a>
</li>
</ul>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" ng-controller="SettingsCtrl">
<div class="row">
<h1 class="page-header">Settings</h1>
</div>
<div class="col-md-9 sans">
{{template "flashes" .Flashes}}
<h1 style="margin:0px 0px 15px 0px;">User Settings</h1>
<div id="flashes" class="row"></div>
<div class="row">
<label for="api_key" class="col-sm-2 control-label form-label">API Key:</label>
<div class="col-md-6">
<input type="text" id="api_key" onclick="this.select();" value="{{.User.ApiKey}}" class="form-control" readonly/>
</div>
<form ng-submit="api_reset()">
<button class="btn btn-primary"><i class="fa fa-refresh" type="submit"></i> Reset</button>
<input type="hidden" name="csrf_token" value="{{.Token}}"/>
</form>
</div>
<br />
<form ngsubmit="save_settings()" method="POST">
<div class="row">
<label for="api_key" class="col-sm-2 control-label form-label">API Key:</label>
<label for="username" class="col-sm-2 control-label form-label">Username:</label>
<div class="col-md-6">
<input type="text" id="api_key" onclick="this.select();" value="{{%.User.ApiKey%}}" class="form-control" readonly/>
<input type="text" id="username" class="form-control" {{.User.Username}} />
</div>
<form action="/api/reset" method="POST">
<button class="btn btn-primary"><i class="fa fa-refresh" type="submit"></i> Reset</button>
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
</form>
</div>
<br />
<form action="/settings" method="POST">
<div class="row">
<label for="username" class="col-sm-2 control-label form-label">Username:</label>
<div class="col-md-6">
<input type="text" id="username" value="{{%.User.Username%}}" class="form-control" />
</div>
<div class="row">
<label for="current_password" class="col-sm-2 control-label form-label">Old Password:</label>
<div class="col-md-6">
<input type="password" id="current_password" name="current_password" class="form-control"/>
</div>
<br />
<div class="row">
<label for="current_password" class="col-sm-2 control-label form-label">Old Password:</label>
<div class="col-md-6">
<input type="password" id="current_password" name="current_password" class="form-control" />
</div>
</div>
<br />
<div class="row">
<label for="new_password" class="col-sm-2 control-label form-label">New Password:</label>
<div class="col-md-6">
<input type="password" id="new_password" name="new_password" class="form-control" />
</div>
<br />
<div class="row">
<label for="new_password" class="col-sm-2 control-label form-label">New Password:</label>
<div class="col-md-6">
<input type="password" id="new_password" name="new_password" class="form-control" />
</div>
</div>
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
<br />
<button class="btn btn-primary" type="submit">Save</button>
</form>
<br/>
</div>
</div>
<input type="hidden" name="csrf_token" {{.Token}}/>
<br />
<button class="btn btn-primary" type="submit">Save</button>
</form>
<br/>
</div>
{{end}}
{{define "scripts"}}
<script src="/js/app/settings.js">
{{end}}

View File

@ -25,27 +25,31 @@
<h1 class="page-header">
Email Templates
</h1>
<div class="row">
<div ng-repeat="flash in flashes.main" style="text-align:center" class="alert alert-{{flash.type}}">
<i class="fa {{flash.icon}}"></i> {{flash.message}}
</div>
</div>
<div id="flashes" class="row"></div>
<div class="row">
<button type="button" class="btn btn-primary" ng-click="editTemplate('new')"><i class="fa fa-plus"></i> New Template</button>
</div>
&nbsp;
<div ng-show="!templates.length">
<div class="row">
<div class="alert alert-info">
No templates created yet. Let's create one!
</div>
<div id="emptyMessage" class="row">
<div class="alert alert-info">
No templates created yet. Let's create one!
</div>
</div>
<div ng-show="templates.length" class="row">
<table id="templateTable" class="table" style="display:none;">
<thead>
<tr>
<th>Name</th>
<th>Modified Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<!-- <div ng-show="templates.length" class="row">
<table ng-table="mainTableParams" class="table table-hover table-striped table-bordered">
<tbody>
<tr ng-repeat="template in $data | orderBy: '-modified_date'" class="editable-row">
<td data-title="'Name'" sortable="'name'" class="col-sm-2">{{template.name}}
<td data-title="'Name'" sortable="'name'" class="col-sm-2">template.name
<div class="btn-group" style="float: right;">
<button type="button" class="btn btn-primary dropdown-toggle edit-button" data-toggle="dropdown">
<span class="caret" style="border-top-color:#FFFFFF"></span>
@ -60,10 +64,13 @@
</ul>
</div>
</td>
<td data-title="'Modified Date'" class="col-sm-1">{{template.modified_date | date:'medium'}}</td>
<td data-title="'Modified Date'" class="col-sm-1">template.modified_date | date:'medium'</td>
</tr>
</tbody>
</table>
</div>
</div> -->
</div>
{{end}}
{{define "scripts"}}
<script src="/js/app/campaigns.js"></script>
{{end}}