Skip to content
Snippets Groups Projects
Commit 3f32921a authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add option to disable oauth apps, default is enabled

parent 14b82405
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,7 @@ rocketchat:mentions-flextab@0.0.1
rocketchat:message-attachments@0.0.1
rocketchat:message-pin@0.0.1
rocketchat:message-star@0.0.1
rocketchat:oauth2-server@1.1.1
rocketchat:oauth2-server@1.2.0
rocketchat:oauth2-server-config@1.0.0
rocketchat:oembed@0.0.1
rocketchat:slashcommands-invite@0.0.1
......
Template.oauthApp.onCreated ->
@record = new ReactiveVar {}
@record = new ReactiveVar
active: true
Template.oauthApp.helpers
......@@ -48,6 +49,7 @@ Template.oauthApp.events
"click .submit > .save": ->
name = $('[name=name]').val().trim()
active = $('[name=active]:checked').val().trim() is "1"
redirectUri = $('[name=redirectUri]').val().trim()
if name is ''
......@@ -58,6 +60,7 @@ Template.oauthApp.events
app =
name: name
active: active
redirectUri: redirectUri
params = Template.instance().data.params?()
......
......@@ -5,10 +5,17 @@
<div class="rocket-form">
<div class="section">
<div class="section-content">
<div class="input-line double-col">
<label>{{_ "Active"}}</label>
<div>
<label><input class="input-monitor" type="radio" name="active" value="1" checked="{{$eq data.active true}}" /> {{_ "True"}}</label>
<label><input class="input-monitor" type="radio" name="active" value="0" checked="{{$eq data.active false}}" /> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col">
<label>{{_ "Application_Name"}}</label>
<div>
<input type="text" name="name" value="{{data.name}}" placeholder="{{_ 'Optional'}}" />
<input type="text" name="name" value="{{data.name}}" />
<div class="settings-description">{{_ "Give_the_application_a_name_This_will_be_seen_by_your_users"}}</div>
</div>
</div>
......
......@@ -15,6 +15,9 @@ Meteor.methods
if application.redirectUri.trim() is ''
throw new Meteor.Error 'invalid_redirectUri', '[methods] addOAuthApp -> redirectUri can\'t be empty'
if not _.isBoolean(application.active)
throw new Meteor.Error 'invalid_active', '[methods] addOAuthApp -> active must be boolean'
application.clientId = Random.id()
application.clientSecret = Random.secret()
application._createdAt = new Date
......
......@@ -15,6 +15,9 @@ Meteor.methods
if application.redirectUri.trim() is ''
throw new Meteor.Error 'invalid_redirectUri', '[methods] updateOAuthApp -> redirectUri can\'t be empty'
if not _.isBoolean(application.active)
throw new Meteor.Error 'invalid_active', '[methods] updateOAuthApp -> active must be boolean'
currentApplication = RocketChat.models.OAuthApps.findOne(applicationId)
if not currentApplication?
throw new Meteor.Error 'invalid_application', '[methods] updateOAuthApp -> application not found'
......@@ -22,6 +25,7 @@ Meteor.methods
RocketChat.models.OAuthApps.update applicationId,
$set:
name: application.name
active: application.active
redirectUri: application.redirectUri
_updatedAt: new Date
_updatedBy: RocketChat.models.Users.findOne @userId, {fields: {username: 1}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment