From cb29fa5694553a3fb5c238f5fcc8348a5e0e8b49 Mon Sep 17 00:00:00 2001 From: Mathew Henson Date: Thu, 14 Apr 2016 00:46:52 +0100 Subject: [PATCH] Updated rest urls for users 0.2.2. See #8 --- admin/lib/authenticator.ts | 2 +- admin/lib/states/login/login-ctrl.ts | 4 ++-- admin/lib/states/media/media-ctrl.ts | 2 +- admin/lib/states/register/register-ctrl.ts | 2 +- admin/lib/states/users/users-ctrl.ts | 4 ++-- test/tests.js | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/lib/authenticator.ts b/admin/lib/authenticator.ts index b76cb008..16da56ca 100644 --- a/admin/lib/authenticator.ts +++ b/admin/lib/authenticator.ts @@ -9,7 +9,7 @@ private _q: ng.IQService; private _usersURL: string; public static user: UsersInterface.IUserEntry; - + // $inject annotation. public static $inject = ["$http", "$q", "usersURL"]; constructor(http: ng.IHttpService, q: ng.IQService, usersURL: string ) diff --git a/admin/lib/states/login/login-ctrl.ts b/admin/lib/states/login/login-ctrl.ts index 23c8b82b..b5f3cd54 100644 --- a/admin/lib/states/login/login-ctrl.ts +++ b/admin/lib/states/login/login-ctrl.ts @@ -34,7 +34,7 @@ this.error = false; this.errorMsg = "Hello"; } - + /** * Attempts to log the user in */ @@ -48,7 +48,7 @@ this.errorMsg = ""; this.loading = true; - this.http.post(`${host}/login`, token).then(function (response) + this.http.post(`${host}/users/login`, token).then(function (response) { var responseToken = response.data; if (responseToken.error) diff --git a/admin/lib/states/media/media-ctrl.ts b/admin/lib/states/media/media-ctrl.ts index 14fbd049..7553cd39 100644 --- a/admin/lib/states/media/media-ctrl.ts +++ b/admin/lib/states/media/media-ctrl.ts @@ -245,7 +245,7 @@ var command = ""; if (that.selectedFolder) - command = `${that.usersURL}/users/${Authenticator.user.username}/buckets/${that.selectedFolder.name}/get-files?index=${index}&limit=${limit}&search=${that.searchTerm}` + command = `${that.usersURL}/users/${Authenticator.user.username}/buckets/${that.selectedFolder.name}/files?index=${index}&limit=${limit}&search=${that.searchTerm}` else command = `${that.usersURL}/users/${Authenticator.user.username}/buckets?index=${index}&limit=${limit}&search=${that.searchTerm}` diff --git a/admin/lib/states/register/register-ctrl.ts b/admin/lib/states/register/register-ctrl.ts index 9658153d..e9280cd8 100644 --- a/admin/lib/states/register/register-ctrl.ts +++ b/admin/lib/states/register/register-ctrl.ts @@ -109,7 +109,7 @@ token.challenge = Recaptcha.get_challenge(); token.captcha = Recaptcha.get_response(); - this.http.post(`${that.usersURL}/register`, token).then(function (response) + this.http.post(`${that.usersURL}/users/register`, token).then(function (response) { var responseToken = response.data; if (responseToken.error) diff --git a/admin/lib/states/users/users-ctrl.ts b/admin/lib/states/users/users-ctrl.ts index 82cdb494..6256fa9c 100644 --- a/admin/lib/states/users/users-ctrl.ts +++ b/admin/lib/states/users/users-ctrl.ts @@ -96,7 +96,7 @@ this.errorMsg = ""; this.loading = true; - that.http.delete(`${that.usersURL}/users/${user.username}/remove-user`).then(function (token) + that.http.delete(`${that.usersURL}/users/${user.username}`).then(function (token) { if (token.data.error) { that.error = true; @@ -128,7 +128,7 @@ registerToken.privileges = registerToken.type == "2" ? 2 : 3; - that.http.post(`${that.usersURL}/create-user`, registerToken).then(function(token) + that.http.post(`${that.usersURL}/users`, registerToken).then(function(token) { if (token.data.error) { that.error = true; diff --git a/test/tests.js b/test/tests.js index 74d10a83..53696bcd 100644 --- a/test/tests.js +++ b/test/tests.js @@ -48,7 +48,7 @@ var tempPost = null; describe('Log in as an admin user', function() { it('logged in with a valid username & valid password', function(done){ usersAgent - .post('/login').set('Accept', 'application/json').expect(200).expect('Content-Type', /json/) + .post('/users/login').set('Accept', 'application/json').expect(200).expect('Content-Type', /json/) .send({username: uconfig.adminUser.username, password: uconfig.adminUser.password }) .end(function(err, res) { test.bool(res.body.error).isNotTrue() @@ -102,7 +102,7 @@ describe('Testing all post related endpoints', function() { done(); }); }) - + it('Cannot create a post without a slug field', function(done) { modepressAgent .post('/api/posts/create-post').set('Accept', 'application/json').expect(200).expect('Content-Type', /json/)