Skip to content

Commit

Permalink
Allow Application#redirect_uri= to handle array of URIs
Browse files Browse the repository at this point in the history
Add entry to NEWS.md
  • Loading branch information
Justin Bull committed Feb 16, 2018
1 parent 3756ec2 commit 7bae2e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ User-visible changes worth mentioning.

## master

- [#1036] Allow to forbid Application redirect URI's with specific rules.
- [#1035] Allow `Application#redirect_uri=` to handle array of URIs.
- [#1036] Allow to forbid Application redirect URI's with specific rules.
- [#1029] Deprecate `order_method` and introduce `ordered_by`. Sort applications
by `created_at` in index action.
- [#1033] Allow Doorkeeper configuration option #force_ssl_in_redirect_uri to be a callable object.
Expand Down
9 changes: 9 additions & 0 deletions lib/doorkeeper/models/application_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def by_uid(uid)
end
end

# Set an application's valid redirect URIs.
#
# @param uris [String, Array] Newline-separated string or array the URI(s)
#
# @return [String] The redirect URI(s) seperated by newlines.
def redirect_uri=(uris)
super(uris.is_a?(Array) ? uris.join("\n") : uris)
end

private

def has_scopes?
Expand Down
15 changes: 15 additions & 0 deletions spec/models/doorkeeper/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@ module Doorkeeper
end
end

describe "#redirect_uri=" do
context "when array of valid redirect_uris" do
it "should join by newline" do
new_application.redirect_uri = ['http://localhost/callback1', 'http://localhost/callback2']
expect(new_application.redirect_uri).to eq("http://localhost/callback1\nhttp://localhost/callback2")
end
end
context "when string of valid redirect_uris" do
it "should store as-is" do
new_application.redirect_uri = "http://localhost/callback1\nhttp://localhost/callback2"
expect(new_application.redirect_uri).to eq("http://localhost/callback1\nhttp://localhost/callback2")
end
end
end

describe :authorized_for do
let(:resource_owner) { double(:resource_owner, id: 10) }

Expand Down

0 comments on commit 7bae2e6

Please sign in to comment.