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 // 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.
params := struct { params := struct {
User models.User User models.User
Title string Title string
@ -255,6 +254,14 @@ func LandingPages(w http.ResponseWriter, r *http.Request) {
// Settings handles the changing of settings // 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 == "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": case r.Method == "POST":
err := auth.ChangePassword(r) err := auth.ChangePassword(r)
msg := models.Response{Success: true, Message: "Settings Updated Successfully"} msg := models.Response{Success: true, Message: "Settings Updated Successfully"}

View File

@ -78,3 +78,6 @@
</div> </div>
</div> </div>
{{end}} {{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="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Gophish - Open-Source Phishing Toolkit"> <meta name="description" content="Gophish - Open-Source Phishing Toolkit">
<meta name="author" content="Jordan Wright (http://github.com/jordan-wright)"> <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> <title>Gophish - {{ .Title }}</title>
@ -54,15 +54,13 @@
{{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">Register</button> <button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
</form> </form>
</div> </div>
<!-- Placed at the end of the document so the pages load faster --> <!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery.js"></script> <script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.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> <script src="/js/ui-bootstrap-0.10.0.min.js"></script>
</body> </body>

View File

@ -1,66 +1,70 @@
{{define "body"}} {{define "body"}}
<div class="jumbotron"> <div class="container-fluid">
<div class="container" style="text-align:center;"> <div class="row">
<h1 class="sans header"> <div class="col-sm-3 col-md-2 sidebar">
Settings <ul class="nav nav-sidebar">
</h1> <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> </div>
<div class="container"> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" ng-controller="SettingsCtrl">
<div class="col-md-3 sidebar"> <div class="row">
<ul class="nav nav-pills nav-stacked"> <h1 class="page-header">Settings</h1>
<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> </div>
<div class="col-md-9 sans"> <div id="flashes" class="row"></div>
{{template "flashes" .Flashes}} <div class="row">
<h1 style="margin:0px 0px 15px 0px;">User Settings</h1> <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"> <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"> <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> </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> </div>
<br /> <br />
<form action="/settings" method="POST"> <div class="row">
<div class="row"> <label for="current_password" class="col-sm-2 control-label form-label">Old Password:</label>
<label for="username" class="col-sm-2 control-label form-label">Username:</label> <div class="col-md-6">
<div class="col-md-6"> <input type="password" id="current_password" name="current_password" class="form-control"/>
<input type="text" id="username" value="{{%.User.Username%}}" class="form-control" />
</div>
</div> </div>
<br /> </div>
<div class="row"> <br />
<label for="current_password" class="col-sm-2 control-label form-label">Old Password:</label> <div class="row">
<div class="col-md-6"> <label for="new_password" class="col-sm-2 control-label form-label">New Password:</label>
<input type="password" id="current_password" name="current_password" class="form-control" /> <div class="col-md-6">
</div> <input type="password" id="new_password" name="new_password" class="form-control" />
</div> </div>
<br /> </div>
<div class="row"> <input type="hidden" name="csrf_token" {{.Token}}/>
<label for="new_password" class="col-sm-2 control-label form-label">New Password:</label> <br />
<div class="col-md-6"> <button class="btn btn-primary" type="submit">Save</button>
<input type="password" id="new_password" name="new_password" class="form-control" /> </form>
</div> <br/>
</div>
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
<br />
<button class="btn btn-primary" type="submit">Save</button>
</form>
<br/>
</div>
</div> </div>
{{end}} {{end}}
{{define "scripts"}}
<script src="/js/app/settings.js">
{{end}}

View File

@ -25,27 +25,31 @@
<h1 class="page-header"> <h1 class="page-header">
Email Templates Email Templates
</h1> </h1>
<div class="row"> <div id="flashes" class="row"></div>
<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 class="row"> <div class="row">
<button type="button" class="btn btn-primary" ng-click="editTemplate('new')"><i class="fa fa-plus"></i> New Template</button> <button type="button" class="btn btn-primary" ng-click="editTemplate('new')"><i class="fa fa-plus"></i> New Template</button>
</div> </div>
&nbsp; &nbsp;
<div ng-show="!templates.length"> <div id="emptyMessage" class="row">
<div class="row"> <div class="alert alert-info">
<div class="alert alert-info"> No templates created yet. Let's create one!
No templates created yet. Let's create one!
</div>
</div> </div>
</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"> <table ng-table="mainTableParams" class="table table-hover table-striped table-bordered">
<tbody> <tbody>
<tr ng-repeat="template in $data | orderBy: '-modified_date'" class="editable-row"> <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;"> <div class="btn-group" style="float: right;">
<button type="button" class="btn btn-primary dropdown-toggle edit-button" data-toggle="dropdown"> <button type="button" class="btn btn-primary dropdown-toggle edit-button" data-toggle="dropdown">
<span class="caret" style="border-top-color:#FFFFFF"></span> <span class="caret" style="border-top-color:#FFFFFF"></span>
@ -60,10 +64,13 @@
</ul> </ul>
</div> </div>
</td> </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> </tr>
</tbody> </tbody>
</table> </table>
</div> </div> -->
</div> </div>
{{end}} {{end}}
{{define "scripts"}}
<script src="/js/app/campaigns.js"></script>
{{end}}