Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SimpleLogin to the available login/signup modules #611

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = function(grunt) {
'src/modules/instagram.js',
'src/modules/joinme.js',
'src/modules/linkedin.js',
'src/modules/simplelogin.js',
'src/modules/soundcloud.js',
'src/modules/spotify.js',
'src/modules/twitter.js',
Expand Down
3 changes: 2 additions & 1 deletion demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ <h2>Web Services</h2>
<li><a href="vimeo.html"> vimeo</a></li>
<li><a href="windows.html"> windows</a></li>
<li><a href="yahoo.html"> yahoo</a></li>
<li><a href="simplelogin.html"> simplelogin</a></li>


<h2>Code sugar</h2>
<li><a href="amd.html"> AMD</a></li>
<li><a href="promises.html"> Promises/A+</a></li>
<li><a href="promises.html"> Promises/A+</a></li>
54 changes: 54 additions & 0 deletions demos/simplelogin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>

<link rel="stylesheet" href="/adorn/adorn.css"/>
<link rel="stylesheet" href="./helper/alert.css"/>
<script src="/adorn/adorn.js" async></script>

<script src="client_ids.js"></script>
<script src="../src/hello.polyfill.js"></script>
<script src="../src/hello.js"></script>
<script src="../src/modules/simplelogin.js"></script>

<title>hello( simplelogin )</title>
<h1>hello( simplelogin )</h1>

<!--simplelogin whitelists localhost development, we don't need to display https alert-->
<!--<script src="./helper/alert-https.js"></script>-->

<blockquote>
<a href="https://docs.simplelogin.io">SimpleLogin Documentation</a>
<a href="https://app.simplelogin.io/developer/new_client">Register App</a>
</blockquote>

<button id='simplelogin' onclick="login('simplelogin');">Connect with SimpleLogin</button>
<pre id="result">Signin to connect with simplelogin</pre>

<script class="pre">
function login(network){

var simplelogin = hello(network);

simplelogin.login()
.then( function(){
// get user profile data
return simplelogin.api( '/me' );
})
.then( function(p){
document.getElementById( network ).innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ network +" as " + p.name;
})
.then(
null,
console.error.bind(console)
);

}
</script>

<script class="pre">
hello.init({
// Register app https://app.simplelogin.io/developer/new_client
simplelogin : 'client-id'
},{
redirect_uri : '../redirect.html'
});
</script>
42 changes: 42 additions & 0 deletions src/modules/simplelogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(function(hello) {
hello.init({

simplelogin: {

name: 'SimpleLogin',

oauth: {
version: 2,
auth: 'https://app.simplelogin.io/oauth2/authorize',
grant: 'https://app.simplelogin.io/oauth2/token'
},

base: 'https://app.simplelogin.io/',

get: {
me: 'oauth2/userinfo'
},

wrap: {
me: function(o) {
if (o.id) {
o.picture = o.thumbnail = o.avatar_url;
}

return o;
}
},

xhr: function(p, qs) {
var token = qs.access_token;
delete qs.access_token;
p.headers.Authorization = 'Bearer ' + token;

return true;
},

jsonp: false
}
});

})(hello);
3 changes: 2 additions & 1 deletion tests/specs/e2e/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define([
'../../../src/modules/github',
'../../../src/modules/bikeindex',
'../../../src/modules/soundcloud',
'../../../src/modules/vk'
'../../../src/modules/vk',
'../../../src/modules/simplelogin'
], function(
errorResponse
) {
Expand Down