Skip to content

Commit

Permalink
ability to add an account within account manager
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDurhamm committed Mar 10, 2019
1 parent f453e01 commit 110e866
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
18 changes: 18 additions & 0 deletions dist/packages/users/Controllers/Manager.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function _index(){
if(array_key_exists('delete-user', $_GET)){
\Twist::Database()->records('twist_users')->delete($_GET['delete-user'],'id');
\Twist::redirect('/manager/users');
//\Twist::noticeMessage('user deleted successfully');
}

foreach ($arrUsers as $arrEachUser){
Expand All @@ -24,6 +25,23 @@ public function _index(){

return $this->_view('manager/users.tpl',$arrTags);
}
public function create(){
return $this->_view('manager/create_user.tpl');
}
public function POSTcreate(){
$resUser = \Twist::User()->current();
$resRecord = \Twist::Database()->records('twist_users')->create();
$resRecord->set('id',$resUser);
$resRecord->set('email',$_POST['email']);
$resRecord->set('firstname',$_POST['firstname']);
$resRecord->set('surname',$_POST['surname']);
$resRecord->set('password',$_POST['password']);
$resRecord->set('level',$_POST['level']);
$addRecordID = $resRecord->commit();


\Twist::redirect('/manager/users');
}

/**
* Override the default view function to append the web sockets view path when required
Expand Down
23 changes: 23 additions & 0 deletions dist/packages/users/Views/manager/create_user.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

<div class="grid-100">
<h2>Create User</h2>
<p>This is where you can create users which will be automatically added to the database to reuse within your app.</p>
<form action="/manager/users/create" method="post">
<label>First Name<sup>*</sup></label>
<input type="text" name="firstname" required>
<label>Surname<sup>*</sup></label>
<input type="text" name="surname" required>
<label>Email<sup>*</sup></label>
<input type="email" name="email" required>
<label>User level<sup>*</sup></label>
<select name="level" id="levels">
<option value="0">Root user</option>
<option value="10">Super Admin</option>
<option value="20">Admin</option>
<option value="30">Normal user</option>
</select>
<label>Password<sup>*</sup></label>
<input type="password" name="password" required>
<button type="submit">Submit</button>
</form>
</div>
2 changes: 1 addition & 1 deletion dist/twist/Core/Resources/manager/css/twistmanager.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 110e866

Please sign in to comment.