fix(client): fix up update flow and redirect uri trim
This commit is contained in:
Родитель
b1f8993cea
Коммит
2c1e3e4f92
|
@ -6,6 +6,15 @@ import Ember from 'ember';
|
|||
import DS from 'ember-data';
|
||||
import config from '../config/environment';
|
||||
|
||||
function fixUpRedirectUri (uri) {
|
||||
if (! uri) {
|
||||
// add some defaults, oauth server requires these fields
|
||||
uri = 'http://';
|
||||
}
|
||||
|
||||
return uri.trim();
|
||||
}
|
||||
|
||||
export default DS.RESTAdapter.extend({
|
||||
/**
|
||||
* API Namespace
|
||||
|
@ -56,12 +65,9 @@ export default DS.RESTAdapter.extend({
|
|||
|
||||
delete data.secret;
|
||||
|
||||
// add some defaults, oauth server requires these fields
|
||||
if (! data.redirect_uri) {
|
||||
data.redirect_uri = 'http://';
|
||||
}
|
||||
data.redirect_uri = fixUpRedirectUri(data.redirect_uri);
|
||||
|
||||
// post process the resuld of 'find'. Need to add the Model type 'client' into the response
|
||||
// post process the result of 'find'. Need to add the Model type 'client' into the response
|
||||
return this.ajax(this.buildURL(type.typeKey, null, record), "POST", { data: data }).then(function (resp) {
|
||||
return { client: resp };
|
||||
});
|
||||
|
@ -83,6 +89,8 @@ export default DS.RESTAdapter.extend({
|
|||
delete data.secret;
|
||||
delete data.trusted;
|
||||
|
||||
data.redirect_uri = fixUpRedirectUri(data.redirect_uri);
|
||||
|
||||
// set POST instead of PUT
|
||||
return this.ajax(this.buildURL(type.typeKey, id, record), "POST", { data: data }).then(function () {
|
||||
data.id = id;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<h3>OAuth Client: <strong>{{name}}</strong></h3>
|
||||
<h3>OAuth Client: <strong>{{model.name}}</strong></h3>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Client ID:</th>
|
||||
<td>{{id}}</td>
|
||||
<td>{{model.id}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Redirect URI</th>
|
||||
<td>{{redirect_uri}}</td>
|
||||
<td>{{model.redirect_uri}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
|
@ -29,7 +29,7 @@
|
|||
<div class="medium-6 columns">
|
||||
<ul class="inline-list right">
|
||||
<li>
|
||||
<button class="small button " {{action 'update' id}}>Update Client</button>
|
||||
<button class="small button " {{action 'update' model.id}}>Update Client</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Загрузка…
Ссылка в новой задаче