-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide default redirect_uri route with oauth_result.tpl template fil…
…e rendering * add default example system_templates/oauth_result.tpl * add controller with /oauth/authentication/result url when oauth_result.tpl is rendered * add documentation for GET /oauth/v2/auth_login route
- Loading branch information
1 parent
752e038
commit 88837e1
Showing
5 changed files
with
194 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
newscoop/src/Newscoop/GimmeBundle/Controller/DefaultController.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*jslint browser: true */ /*global jQuery: true */ | ||
|
||
/** | ||
* jQuery Cookie plugin | ||
* | ||
* Copyright (c) 2010 Klaus Hartl (stilbuero.de) | ||
* Dual licensed under the MIT and GPL licenses: | ||
* http://www.opensource.org/licenses/mit-license.php | ||
* http://www.gnu.org/licenses/gpl.html | ||
* | ||
*/ | ||
|
||
// TODO JsDoc | ||
|
||
/** | ||
* Create a cookie with the given key and value and other optional parameters. | ||
* | ||
* @example $.cookie('the_cookie', 'the_value'); | ||
* @desc Set the value of a cookie. | ||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); | ||
* @desc Create a cookie with all available options. | ||
* @example $.cookie('the_cookie', 'the_value'); | ||
* @desc Create a session cookie. | ||
* @example $.cookie('the_cookie', null); | ||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain | ||
* used when the cookie was set. | ||
* | ||
* @param String key The key of the cookie. | ||
* @param String value The value of the cookie. | ||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes. | ||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. | ||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted. | ||
* If set to null or omitted, the cookie will be a session cookie and will not be retained | ||
* when the the browser exits. | ||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). | ||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). | ||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will | ||
* require a secure protocol (like HTTPS). | ||
* @type undefined | ||
* | ||
* @name $.cookie | ||
* @cat Plugins/Cookie | ||
* @author Klaus Hartl/klaus.hartl@stilbuero.de | ||
*/ | ||
|
||
/** | ||
* Get the value of a cookie with the given key. | ||
* | ||
* @example $.cookie('the_cookie'); | ||
* @desc Get the value of a cookie. | ||
* | ||
* @param String key The key of the cookie. | ||
* @return The value of the cookie. | ||
* @type String | ||
* | ||
* @name $.cookie | ||
* @cat Plugins/Cookie | ||
* @author Klaus Hartl/klaus.hartl@stilbuero.de | ||
*/ | ||
jQuery.cookie = function (key, value, options) { | ||
|
||
// key and value given, set cookie... | ||
if (arguments.length > 1 && (value === null || typeof value !== "object")) { | ||
options = jQuery.extend({}, options); | ||
|
||
if (value === null) { | ||
options.expires = -1; | ||
} | ||
|
||
if (typeof options.expires === 'number') { | ||
var days = options.expires, t = options.expires = new Date(); | ||
t.setDate(t.getDate() + days); | ||
} | ||
|
||
return (document.cookie = [ | ||
encodeURIComponent(key), '=', | ||
options.raw ? String(value) : encodeURIComponent(String(value)), | ||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE | ||
options.path ? '; path=' + options.path : '', | ||
options.domain ? '; domain=' + options.domain : '', | ||
options.secure ? '; secure' : '' | ||
].join('')); | ||
} | ||
|
||
// key and possibly options given, get cookie... | ||
options = value || {}; | ||
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; | ||
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{{ dynamic }} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Newscoop Oauth Authentication Result</title> | ||
|
||
<!-- Bootstrap core CSS --> | ||
<link href="/themes/system_templates/css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="/themes/system_templates/css/main.css" rel="stylesheet"> | ||
<style type="text/css" media="screen"> | ||
body { | ||
padding-top: 40px; | ||
padding-bottom: 40px; | ||
background-color: #eee; | ||
} | ||
#container { | ||
max-width: 320px; | ||
padding: 15px; | ||
margin: 0 auto; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="container"> | ||
<img src="/themes/system_templates/img/newscoop_logo_big.png" /> | ||
<h1 class="form-signin-heading text-muted">Authentication is finished</h1> | ||
<p>Check result in this page url (with javascript) and continue with returned data</p> | ||
</div> | ||
|
||
<!-- Placed at the end of the document so the pages load faster --> | ||
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script> | ||
<script src="/themes/system_templates/js/jquery.cookie.js"></script> | ||
<script src="/themes/system_templates/js/bootstrap.min.js"></script> | ||
<script type="text/javascript"> | ||
function getHashParams() { | ||
var hashParams = {}; | ||
var e,a = /\+/g,r = /([^&;=]+)=?([^&;]*)/g,d = function (s) { return decodeURIComponent(s.replace(a, " ")); },q = window.location.hash.substring(1); | ||
while (e = r.exec(q))hashParams[d(e[1])] = d(e[2]); | ||
return hashParams; | ||
} | ||
var hashParams = getHashParams(); | ||
// check if authentication was succesfull and play with access_token | ||
if (jQuery.inArray("access_token", hashParams)) { | ||
console.log('Your access_token is: ' + hashParams.access_token); | ||
if ($.cookie('newscoop_access_token') == null || $.cookie('newscoop_access_token') != hashParams.access_token) { | ||
// create new cookie with access_token value | ||
console.log('Creating cookie with access_token value'); | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (hashParams.expires_in * 1000)); | ||
$.cookie('newscoop_access_token', hashParams.access_token, { expires: date, path: '/' }); | ||
} else { | ||
console.log('You have valid access_token under "newscoop_access_token" cookie'); | ||
} | ||
} else if (jQuery.inArray("error", hashParams)) { | ||
// there was an error on authentication process | ||
console.log('error:' + hashParams.error); | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
{{ /dynamic }} |