Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions packages/rocketchat-api/server/v1/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@ RocketChat.API.v1.addRoute('info', { authRequired: false }, {
}
});

RocketChat.API.v1.addRoute('settings.oauth', { authRequired: false }, {
get() {
const mountOAuthServices = () => {
const oAuthServicesEnabled = ServiceConfiguration.configurations.find({}).fetch();

return oAuthServicesEnabled.map((service) => {
return {
id: service._id,
name: service.service,
appId: service.appId || service.clientId,
buttonLabelText: service.buttonLabelText || '',
buttonColor: service.buttonColor || '',
buttonLabelColor: service.buttonLabelColor || ''
};
});
};

return RocketChat.API.v1.success({
services: mountOAuthServices()
});
}
});

RocketChat.API.v1.addRoute('me', { authRequired: true }, {
get() {
const me = _.pick(this.user, [
Expand Down
29 changes: 28 additions & 1 deletion packages/rocketchat-api/server/v1/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ RocketChat.API.v1.addRoute('settings.public', { authRequired: false }, {
}
});

RocketChat.API.v1.addRoute('settings.oauth', { authRequired: false }, {
get() {
const mountOAuthServices = () => {
const oAuthServicesEnabled = ServiceConfiguration.configurations.find({}).fetch();

return oAuthServicesEnabled.map((service) => {
if (service.custom) {
return { ...service };
}
return {
id: service._id,
name: service.service,
clientId: service.appId || service.clientId,
buttonLabelText: service.buttonLabelText || '',
buttonColor: service.buttonColor || '',
buttonLabelColor: service.buttonLabelColor || '',
custom: false
};
});
};

return RocketChat.API.v1.success({
services: mountOAuthServices()
});
}
});

RocketChat.API.v1.addRoute('settings', { authRequired: true }, {
get() {
const { offset, count } = this.getPaginationItems();
Expand Down Expand Up @@ -90,7 +117,7 @@ RocketChat.API.v1.addRoute('service.configurations', { authRequired: false }, {
const ServiceConfiguration = Package['service-configuration'].ServiceConfiguration;

return RocketChat.API.v1.success({
configurations: ServiceConfiguration.configurations.find({}, {fields: {secret: 0}}).fetch()
configurations: ServiceConfiguration.configurations.find({}, { fields: { secret: 0 } }).fetch()
});
}
});
24 changes: 0 additions & 24 deletions tests/end-to-end/api/00-miscellaneous.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,5 @@ describe('miscellaneous', function() {
.end(done);
});

describe('/settings.oauth', () => {
it('should have return list of available oauth services when user is not logged', (done) => {
request.get(api('settings.oauth'))
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});

it('should have return list of available oauth services when user is logged', (done) => {
request.get(api('settings.oauth'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});
});

});
25 changes: 25 additions & 0 deletions tests/end-to-end/api/08-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,29 @@ describe('[Settings]', function() {
.end(done);
});
});

describe('/settings.oauth', () => {
it('should have return list of available oauth services when user is not logged', (done) => {
request.get(api('settings.oauth'))
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});

it('should have return list of available oauth services when user is logged', (done) => {
request.get(api('settings.oauth'))
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('services').and.to.be.an('array');
})
.end(done);
});
});
});