mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
Merge branch 'master' into github-tidy-up
This commit is contained in:
commit
f8b62796f9
2 changed files with 94 additions and 94 deletions
|
@ -31,7 +31,7 @@ export default Ember.Service.extend({
|
||||||
setupMode: false,
|
setupMode: false,
|
||||||
|
|
||||||
getBaseUrl(endpoint) {
|
getBaseUrl(endpoint) {
|
||||||
return [this.get('host'), endpoint].join('/');
|
return [this.get('endpoint'), endpoint].join('/');
|
||||||
},
|
},
|
||||||
|
|
||||||
boot(/*requestedUrl*/) {
|
boot(/*requestedUrl*/) {
|
||||||
|
|
|
@ -13,117 +13,117 @@ import Ember from 'ember';
|
||||||
import models from '../utils/model';
|
import models from '../utils/model';
|
||||||
|
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
sessionService: Ember.inject.service('session'),
|
sessionService: Ember.inject.service('session'),
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
|
||||||
// Adds a new user.
|
// Adds a new user.
|
||||||
add(user) {
|
add(user) {
|
||||||
|
|
||||||
return this.get('ajax').request(`users`, {
|
return this.get('ajax').request(`users`, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: JSON.stringify(user),
|
data: JSON.stringify(user),
|
||||||
contentType: 'json'
|
contentType: 'json'
|
||||||
}).then(function(response){
|
}).then(function (response) {
|
||||||
return models.UserModel.create(response);
|
return models.UserModel.create(response);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns user model for specified user id.
|
// Returns user model for specified user id.
|
||||||
getUser(userId) {
|
getUser(userId) {
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
type: 'GET'
|
type: 'GET'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return models.UserModel.create(response);
|
return models.UserModel.create(response);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns all users for organization.
|
// Returns all users for organization.
|
||||||
getAll() {
|
getAll() {
|
||||||
return this.get('ajax').request(`users`).then((response) => {
|
return this.get('ajax').request(`users`).then((response) => {
|
||||||
return response.map(function(obj){
|
return response.map(function (obj) {
|
||||||
return models.UserModel.create(obj);
|
return models.UserModel.create(obj);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns all users that can see folder.
|
// Returns all users that can see folder.
|
||||||
getFolderUsers(folderId) {
|
getFolderUsers(folderId) {
|
||||||
let url = `users/folder/${folderId}`;
|
let url = `users/folder/${folderId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: "GET"
|
method: "GET"
|
||||||
}).then((response)=>{
|
}).then((response) => {
|
||||||
let data = [];
|
let data = [];
|
||||||
_.each(response, function(obj) {
|
_.each(response, function (obj) {
|
||||||
data.pushObject(models.UserModel.create(obj));
|
data.pushObject(models.UserModel.create(obj));
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Updates an existing user record.
|
// Updates an existing user record.
|
||||||
save(user) {
|
save(user) {
|
||||||
let userId = user.get('id');
|
let userId = user.get('id');
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: JSON.stringify(user),
|
data: JSON.stringify(user),
|
||||||
contentType: 'json'
|
contentType: 'json'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// updatePassword changes the password for the specified user.
|
// updatePassword changes the password for the specified user.
|
||||||
updatePassword(userId, password) {
|
updatePassword(userId, password) {
|
||||||
let url = `users/${userId}/password`;
|
let url = `users/${userId}/password`;
|
||||||
|
|
||||||
return this.get('ajax').post(url, {
|
return this.get('ajax').post(url, {
|
||||||
data: password
|
data: password
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Removes the specified user.
|
// Removes the specified user.
|
||||||
remove(userId) {
|
remove(userId) {
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Request password reset.
|
// Request password reset.
|
||||||
forgotPassword(email) {
|
forgotPassword(email) {
|
||||||
let url = `public/forgot`;
|
let url = `public/forgot`;
|
||||||
|
|
||||||
if (is.empty(email)) {
|
if (is.empty(email)) {
|
||||||
return Ember.RSVP.reject("invalid");
|
return Ember.RSVP.reject("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = JSON.stringify({
|
let data = JSON.stringify({
|
||||||
Email: email
|
email: email
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set new password.
|
// Set new password.
|
||||||
resetPassword(token, password) {
|
resetPassword(token, password) {
|
||||||
var url = `public/reset/${token}`;
|
var url = `public/reset/${token}`;
|
||||||
|
|
||||||
if (is.empty(token) || is.empty(password)) {
|
if (is.empty(token) || is.empty(password)) {
|
||||||
return Ember.RSVP.reject("invalid");
|
return Ember.RSVP.reject("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: password
|
data: password
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue