sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0

[web] permissions added

This commit is contained in:
Martin Geno 2016-09-11 18:40:03 +02:00
parent 6d1290e159
commit ed433dc66f
26 changed files with 396 additions and 43 deletions

View File

@ -18,6 +18,8 @@
"angular-bootstrap": "^1.3.3", "angular-bootstrap": "^1.3.3",
"bootstrap": "^3.3.6", "bootstrap": "^3.3.6",
"bootswatch": "^3.3.7", "bootswatch": "^3.3.7",
"ng-table": "^1.0.0" "ng-table": "^1.0.0",
"angular-ui-select": "^0.19.4",
"angular-sanitize": "^1.5.8"
} }
} }

5
public/app/admin.jade Normal file
View File

@ -0,0 +1,5 @@
div(ng-if="session.login.superadmin",ui-view="")
div(ng-if="!session.login.superadmin")
.container
h1 No Permissions
.alert.alert-danger This area is only for a admins visible!

View File

@ -1,8 +1,10 @@
'use strict'; 'use strict';
angular.module('warehost', [ angular.module('warehost', [
'ngSanitize',
'ui.router', 'ui.router',
'ui.bootstrap', 'ui.bootstrap',
'ui.select',
'ngTable', 'ngTable',
'config', 'config',
'session', 'session',

View File

@ -1,10 +0,0 @@
'use strict';
angular.module('config', [])
.factory('config', function() {
return {
api: 'https://apiv2.warehost.de',
table: {
count: 25
}
};
});

View File

@ -16,14 +16,22 @@ angular.module('warehost')
.state('app.L', { .state('app.L', {
templateUrl: 'app/loggedin.html' templateUrl: 'app/loggedin.html'
}) })
.state('app.L.settings', { .state('app.L.setting', {
url:'/settings', url:'/settings',
templateUrl: 'app/settings.html', templateUrl: 'app/setting.html',
controller: 'SettingsCtrl' controller: 'SettingCtrl'
}) })
.state('app.L.invites', { .state('app.L.invite', {
url:'/invites', url:'/invites',
templateUrl: 'app/invites.html', templateUrl: 'app/invite.html',
controller: 'InvitesCtrl' controller: 'InviteCtrl'
})
.state('app.A', {
templateUrl: 'app/admin.html'
})
.state('app.A.user', {
url:'/user',
templateUrl: 'app/user.html',
controller: 'UserCtrl'
}); });
}]); }]);

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('warehost') angular.module('warehost')
.controller('InvitesCtrl',function(session,config,alert,NgTableParams,$scope,$http){ .controller('InviteCtrl',function(session,config,alert,NgTableParams,$scope,$http){
$scope.tableParams = new NgTableParams({ $scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' }, sorting: { 'invited.username': 'asc' },
total: 0, total: 0,
@ -42,10 +42,10 @@ angular.module('warehost')
$scope.edit = function(a){ $scope.edit = function(a){
a.invited.password = a.newPassword; a.invited.password = a.newPassword;
$http.put(config.api+'/invite/'+a.invited.ID,a.invited).then(submitresult); $http.put(config.api+'/user/'+a.invited.ID,a.invited).then(submitresult);
}; };
$scope.delete = function(a){ $scope.delete = function(a){
$http.delete(config.api+'/invite/'+a.invited.ID).then(submitresult); $http.delete(config.api+'/user/'+a.invited.ID).then(submitresult);
}; };
$scope.add = function(){ $scope.add = function(){
$http.post(config.api+'/invite',$scope.obj).then(submitresult); $http.post(config.api+'/invite',$scope.obj).then(submitresult);

View File

@ -31,15 +31,15 @@
span.caret span.caret
ul.dropdown-menu ul.dropdown-menu
li li
a(ui-sref="app.L.invites",ui-sref-active="active") a(ui-sref="app.L.invite",ui-sref-active="active")
span.glyphicon.glyphicon-send span.glyphicon.glyphicon-send
| Invites | Invites
li(ng-if="session.login.superadmin") li(ng-if="session.login.superadmin")
a(ui-sref="app.A.admin",ui-sref-active="active") a(ui-sref="app.A.user",ui-sref-active="active")
span.glyphicon.glyphicon-tasks span.glyphicon.glyphicon-tasks
| User Managment | User Managment
li li
a(ui-sref="app.L.settings",ui-sref-active="active") a(ui-sref="app.L.setting",ui-sref-active="active")
span.glyphicon.glyphicon-cog span.glyphicon.glyphicon-cog
| Settings | Settings
li li

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('warehost') angular.module('warehost')
.controller('SettingsCtrl',function(session,config,alert,$scope,$http){ .controller('SettingCtrl',function(session,config,alert,$scope,$http){
$scope.obj = {}; $scope.obj = {};
alert.set({}); alert.set({});
$scope.submit = function(){ $scope.submit = function(){

48
public/app/user.jade Normal file
View File

@ -0,0 +1,48 @@
.container
h1 User Managment
a.btn.btn-default(ng-click="isAdding=true")
span.glyphicon.glyphicon-plus
form(ng-submit="add()",name="addform",ng-if="isAdding")
.form-group
label(for="username") Username
input.form-control(id="username",name="username",ng-model="obj.username",ng-minlength="3")
.form-group(ng-class="{'has-error': (error.fields.indexOf('newpassword') >= 0 || !addform.newPassword.$valid)}")
label(for="newPassword") New Password
input.form-control(id="newPassword",type="password",name="newPassword",ng-model="obj.password",ng-minlength="3")
.form-group(ng-class="{'has-error': (obj.password != obj.repeatPassword && addform.repeatPassword.$dirty)}")
label(for="repeatPassword") Again Password
input.form-control(id="repeatPassword",type="password",name="repeatPassword",ng-model="obj.repeatPassword")
button.btn.btn-primary(type="submit")
span.glyphicon.glyphicon-floppy-disk
| Save
table.table.table-bordered(ng-table="tableParams")
tr(ng-hide='group.$hideRows',ng-repeat="item in $data")
td(data-title="'#'") {{item.ID}}
td(data-title="'Username'", filter="{'username': 'text'}")
span(ng-if="!item.isEditing") {{item.username}}
h4(ng-if="item.isEditing") Username: {{item.username}}
form(name="myform",ng-if="item.isEditing")
.form-group(ng-class="{'has-error': (error.fields.indexOf('username') >= 0 || !myform.username.$valid)}")
label(for="username") Username
input.form-control(id="username",name="username",ng-model="item.username")
.form-group(ng-class="{'has-error': (error.fields.indexOf('newpassword') >= 0 || !myform.newPassword.$valid)}")
label(for="newPassword") New Password
input.form-control(id="newPassword",type="password",name="newPassword",ng-model="item.newPassword",ng-minlength="3")
.form-group(ng-class="{'has-error': (item.newPassword != item.repeatPassword && myform.repeatPassword.$dirty)}")
label(for="repeatPassword") Again Password
input.form-control(id="repeatPassword",type="password",name="repeatPassword",ng-model="item.repeatPassword")
.form-group
label
input(type="checkbox",ng-model="item.superadmin")
| Administrator
td(data-title="'Administrator'", filter="{'superadmin': 'components/ngfilter-boolean.html'}")
span.glyphicon.glyphicon-ok(ng-if="item.superadmin")
span.glyphicon.glyphicon-remove(ng-if="!item.superadmin")
td(data-title="'Option'")
.btn-group.btn-group-xs(ng-if="item.admin || item.createat >= item.lastloginat")
span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing")
span.glyphicon.glyphicon-pencil
span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing")
span.glyphicon.glyphicon-remove-circle
span.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-trash

45
public/app/user.js Normal file
View File

@ -0,0 +1,45 @@
'use strict';
angular.module('warehost')
.controller('UserCtrl',function(session,config,alert,NgTableParams,$scope,$http){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({});
$scope.obj = {};
$scope.invitor = {};
function resetObj(){
$scope.obj = {};
}
function load(){
$http.get(config.api+'/user').then(function(res){
session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
load();
resetObj();
$scope.isAdding = false;
}
}
resetObj();
load();
$scope.edit = function(a){
a.password = a.newPassword;
$http.put(config.api+'/user/'+a.ID,a).then(submitresult);
};
$scope.delete = function(a){
$http.delete(config.api+'/user/'+a.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/user',$scope.obj).then(submitresult);
};
});

View File

@ -22,5 +22,41 @@ angular.module('warehost')
views:{ views:{
'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'} 'menu':{templateUrl:'app/web/menu.html',controller:'MenuWebCtrl'}
} }
})
.state('app.webS.menu', {
url:'/menu',
views:{
'@app':{
templateUrl: 'app/web/webmenu.html',
controller:'WebmenuWebCtrl'
}
}
})
.state('app.webS.domain', {
url:'/domain',
views:{
'@app':{
templateUrl: 'app/web/domain.html',
controller:'DomainWebCtrl'
}
}
})
.state('app.webS.page', {
url:'/page',
views:{
'@app':{
templateUrl: 'app/web/page.html',
controller:'PageWebCtrl'
}
}
})
.state('app.webS.permission', {
url:'/permission',
views:{
'@app':{
templateUrl: 'app/web/permission.html',
controller:'PermissionWebCtrl'
}
}
}); });
}]); }]);

View File

@ -11,8 +11,10 @@ li.dropdown
li(ng-repeat="item in list") li(ng-repeat="item in list")
a(ui-sref="app.webS({websiteid:item.website.ID})") {{item.website.name}} a(ui-sref="app.webS({websiteid:item.website.ID})") {{item.website.name}}
li(ng-if="website.name") li(ng-if="website.name")
a Menu a(ui-sref="app.webS.menu({websiteid:website.ID})") Menu
li(ng-if="website.name") li(ng-if="website.name")
a Seiten a(ui-sref="app.webS.page({websiteid:website.ID})") Pages
li(ng-if="website.name") li(ng-if="website.name")
a Permissions a(ui-sref="app.webS.domain({websiteid:website.ID})") Domains
li(ng-if="website.name")
a(ui-sref="app.webS.permission({websiteid:website.ID})") Permissions

View File

@ -12,7 +12,7 @@ angular.module('warehost')
$scope.list = res.data.data; $scope.list = res.data.data;
for(var key in res.data.data){ for(var key in res.data.data){
var item = res.data.data[key]; var item = res.data.data[key];
if(item.website.ID === $stateParams.websiteid){ if(item.website.ID+"" === $stateParams.websiteid){
$scope.website = item.website; $scope.website = item.website;
} }
} }

28
public/app/web/page.jade Normal file
View File

@ -0,0 +1,28 @@
.container
h1 Pages
a.btn.btn-default(ng-click="isAdding=true")
span.glyphicon.glyphicon-plus
form(ng-submit="add()",name="addform",ng-if="isAdding")
.form-group
label(for="name") Name
input.form-control(id="name",name="name",ng-model="obj.name",ng-minlength="3")
button.btn.btn-primary(type="submit")
span.glyphicon.glyphicon-floppy-disk
| Save
table.table.table-bordered(ng-table="tableParams")
tr(ng-hide='group.$hideRows',ng-repeat="item in $data")
td(data-title="'#'") {{item.website.ID}}
td(data-title="'Name'")
span(ng-if="!item.isEditing") {{item.website.name}}
form(name="myform",ng-if="item.isEditing")
.form-group(ng-class="{'has-error': (error.fields.indexOf('name') >= 0 || !myform.name.$valid)}")
label(for="name") Name
input.form-control(id="name",name="name",ng-model="item.website.name")
td(data-title="'Option'")
.btn-group.btn-group-xs
span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing")
span.glyphicon.glyphicon-pencil
span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing")
span.glyphicon.glyphicon-remove-circle
span.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-trash

42
public/app/web/page.js Normal file
View File

@ -0,0 +1,42 @@
'use strict';
angular.module('warehost')
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({});
$scope.obj = {};
function resetObj(){
$scope.obj = {};
}
function load(){
$http.get(config.api+'/web/'+$stateParams.websiteid+'/page').then(function(res){
session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
resetObj();
$scope.isAdding = false;
}
}
resetObj();
load();
$scope.edit = function(a){
$http.put(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID,a.website).then(submitresult);
};
$scope.delete = function(a){
$http.delete(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/web/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
};
});

View File

@ -0,0 +1,22 @@
.container
h1 Permissions
a.btn.btn-default(ng-click="isAdding=true")
span.glyphicon.glyphicon-plus
form(ng-submit="add()",name="addform",ng-if="isAdding")
.form-group
ui-select(ng-model="obj.login",theme="bootstrap")
ui-select-match {{$select.selected.username}}
ui-select-choices(repeat="item in loginlist | filter: $select.search")
div(ng-bind-html="item.username | highlight: $select.search")
button.btn.btn-primary(type="submit")
span.glyphicon.glyphicon-floppy-disk
| Save
table.table.table-bordered(ng-table="tableParams")
tr(ng-hide='group.$hideRows',ng-repeat="item in $data")
td(data-title="'#'") {{item.login.ID}}
td(data-title="'Username'")
span(ng-if="!item.isEditing") {{item.login.username}}
td(data-title="'Option'")
.btn-group.btn-group-xs
span.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-trash

View File

@ -0,0 +1,44 @@
'use strict';
angular.module('warehost')
.controller('PermissionWebCtrl',function(session,config,alert,NgTableParams,$scope,$http,$stateParams){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({});
$scope.obj = {};
$scope.loginlist = [];
function resetObj(){
$scope.obj = {};
}
function load(){
$http.get(config.api+'/user/').then(function(res){
$scope.loginlist = res.data.data;
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/permission').then(function(res){
session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
});
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
resetObj();
$scope.isAdding = false;
load();
}
}
resetObj();
load();
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+a.login.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/permission/'+$scope.obj.login.ID,{}).then(submitresult);
};
});

View File

@ -0,0 +1,28 @@
.container
h1 Menu
a.btn.btn-default(ng-click="isAdding=true")
span.glyphicon.glyphicon-plus
form(ng-submit="add()",name="addform",ng-if="isAdding")
.form-group
label(for="name") Name
input.form-control(id="name",name="name",ng-model="obj.name",ng-minlength="3")
button.btn.btn-primary(type="submit")
span.glyphicon.glyphicon-floppy-disk
| Save
table.table.table-bordered(ng-table="tableParams")
tr(ng-hide='group.$hideRows',ng-repeat="item in $data")
td(data-title="'#'") {{item.website.ID}}
td(data-title="'Name'")
span(ng-if="!item.isEditing") {{item.website.name}}
form(name="myform",ng-if="item.isEditing")
.form-group(ng-class="{'has-error': (error.fields.indexOf('name') >= 0 || !myform.name.$valid)}")
label(for="name") Name
input.form-control(id="name",name="name",ng-model="item.website.name")
td(data-title="'Option'")
.btn-group.btn-group-xs
span.btn.btn-default(ng-click="item.isEditing = true",ng-if="!item.isEditing")
span.glyphicon.glyphicon-pencil
span.btn.btn-default(ng-click="edit(item)",ng-if="item.isEditing")
span.glyphicon.glyphicon-remove-circle
span.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-trash

44
public/app/web/webmenu.js Normal file
View File

@ -0,0 +1,44 @@
'use strict';
angular.module('warehost')
.controller('WebmenuWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){
$scope.tableParams = new NgTableParams({
sorting: { 'invited.username': 'asc' },
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({});
$scope.obj = {};
function resetObj(){
$scope.obj = {};
}
function load(){
$http.get(config.api+'/web/involve').then(function(res){
session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
$rootScope.$broadcast('warehost.web.website.update');
resetObj();
$scope.isAdding = false;
}
}
resetObj();
load();
$rootScope.$on('warehost.web.website.update',load);
$scope.edit = function(a){
$http.put(config.api+'/web/website/'+a.website.ID,a.website).then(submitresult);
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+a.website.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/web/website',$scope.obj).then(submitresult);
};
});

View File

@ -19,6 +19,7 @@
<!-- endbower --> <!-- endbower -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/angular-ui-select/dist/select.min.css" />
<script src="bower_components/ng-table/dist/ng-table.min.css"></script> <script src="bower_components/ng-table/dist/ng-table.min.css"></script>
<!-- endbuild --> <!-- endbuild -->
<!-- build:css({.tmp,public}) app/app.css --> <!-- build:css({.tmp,public}) app/app.css -->
@ -44,21 +45,27 @@
<script src="bower_components/ng-table/dist/ng-table.js"></script> <script src="bower_components/ng-table/dist/ng-table.js"></script>
<!-- endbower --> <!-- endbower -->
<script src="bower_components/ng-table/dist/ng-table.min.js"></script> <script src="bower_components/ng-table/dist/ng-table.min.js"></script>
<script src="bower_components/angular-ui-select/dist/select.min.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<!-- endbuild --> <!-- endbuild -->
<!-- build:js({.tmp,public}) app/app.js --> <!-- build:js({.tmp,public}) app/app.js -->
<script src="app/app.js"></script> <script src="app/app.js"></script>
<!-- injector:js --> <!-- injector:js -->
<script src="app/components/alert.js"></script>
<script src="app/components/config.js"></script>
<script src="app/components/session.js"></script>
<script src="app/host/index.js"></script> <script src="app/host/index.js"></script>
<script src="app/index.js"></script> <script src="app/index.js"></script>
<script src="app/invites.js"></script> <script src="app/invite.js"></script>
<script src="app/main.js"></script> <script src="app/main.js"></script>
<script src="app/settings.js"></script> <script src="app/setting.js"></script>
<script src="app/user.js"></script>
<script src="app/web/index.js"></script> <script src="app/web/index.js"></script>
<script src="app/web/list.js"></script> <script src="app/web/list.js"></script>
<script src="app/web/menu.js"></script> <script src="app/web/menu.js"></script>
<script src="app/web/page.js"></script>
<script src="app/web/permission.js"></script>
<script src="app/web/webmenu.js"></script>
<script src="components/alert.js"></script>
<script src="components/config.js"></script>
<script src="components/session.js"></script>
<!-- endinjector --> <!-- endinjector -->
<!-- endbuild --> <!-- endbuild -->
</body> </body>

View File

@ -246,7 +246,7 @@ describe('API',->
describe('edit',-> describe('edit',->
it('-> not invited/exists',(done)-> it('-> not invited/exists',(done)->
lib.login({username:'test',password:'test'},(j)-> lib.login({username:'test',password:'test'},(j)->
request({method: 'PUT',uri:config.ADDRESS+"/invite/"+1,jar:j,json:{ request({method: 'PUT',uri:config.ADDRESS+"/user/"+1,jar:j,json:{
username: 'test_not_exits', username: 'test_not_exits',
password:'test' password:'test'
}},(err,res,body)-> }},(err,res,body)->
@ -272,7 +272,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_admin") invited = getIndexOfInvitedUsername(body.data,"test_admin")
request({method: 'PUT',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j,json:{ request({method: 'PUT',uri:config.ADDRESS+"/user/"+invited.ID,jar:j,json:{
username:'test2_admin', username:'test2_admin',
password:'test2_admin' password:'test2_admin'
}},(err,res,body)-> }},(err,res,body)->
@ -311,7 +311,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_not_used") invited = getIndexOfInvitedUsername(body.data,"test_not_used")
request({method: 'PUT',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j,json:{ request({method: 'PUT',uri:config.ADDRESS+"/user/"+invited.ID,jar:j,json:{
username:'test2_not_used', username:'test2_not_used',
password:'test2' password:'test2'
}},(err,res,body)-> }},(err,res,body)->
@ -352,7 +352,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_used") invited = getIndexOfInvitedUsername(body.data,"test_used")
request({method: 'PUT',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j,json:{ request({method: 'PUT',uri:config.ADDRESS+"/user/"+invited.ID,jar:j,json:{
username:'test2_not_used', username:'test2_not_used',
password:'test2' password:'test2'
}},(err,res,body)-> }},(err,res,body)->
@ -381,7 +381,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test") invited = getIndexOfInvitedUsername(body.data,"test")
request({method: 'PUT',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j,json:{ request({method: 'PUT',uri:config.ADDRESS+"/user/"+invited.ID,jar:j,json:{
username:'test2', username:'test2',
password:'test2' password:'test2'
}},(err,res,body)-> }},(err,res,body)->
@ -401,7 +401,7 @@ describe('API',->
describe('delete',-> describe('delete',->
it('-> not invited/exists',(done)-> it('-> not invited/exists',(done)->
lib.login({username:'test2',password:'test2'},(j)-> lib.login({username:'test2',password:'test2'},(j)->
request({method: 'DELETE',uri:config.ADDRESS+"/invite/"+1,jar:j},(err,res,body)-> request({method: 'DELETE',uri:config.ADDRESS+"/user/"+1,jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
if(typeof body == "string") if(typeof body == "string")
@ -424,7 +424,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_admin") invited = getIndexOfInvitedUsername(body.data,"test_admin")
request({method: 'DELETE',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j},(err,res,body)-> request({method: 'DELETE',uri:config.ADDRESS+"/user/"+invited.ID,jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
if(typeof body == "string") if(typeof body == "string")
@ -448,7 +448,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_not_used") invited = getIndexOfInvitedUsername(body.data,"test_not_used")
request({method: 'DELETE',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j},(err,res,body)-> request({method: 'DELETE',uri:config.ADDRESS+"/user/"+invited.ID,jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
if(typeof body == "string") if(typeof body == "string")
@ -472,7 +472,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test_used") invited = getIndexOfInvitedUsername(body.data,"test_used")
request({method: 'DELETE',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j},(err,res,body)-> request({method: 'DELETE',uri:config.ADDRESS+"/user/"+invited.ID,jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
if(typeof body == "string") if(typeof body == "string")
@ -496,7 +496,7 @@ describe('API',->
expect(body.data).to.be.a("array") expect(body.data).to.be.a("array")
expect(body.session.login).to.not.be.null expect(body.session.login).to.not.be.null
invited = getIndexOfInvitedUsername(body.data,"test2") invited = getIndexOfInvitedUsername(body.data,"test2")
request({method: 'DELETE',uri:config.ADDRESS+"/invite/"+invited.ID,jar:j},(err,res,body)-> request({method: 'DELETE',uri:config.ADDRESS+"/user/"+invited.ID,jar:j},(err,res,body)->
expect(err).to.be.null expect(err).to.be.null
expect(res.statusCode).to.be.equal(200) expect(res.statusCode).to.be.equal(200)
if(typeof body == "string") if(typeof body == "string")