[auth] Update providers to match web spec

This commit is contained in:
Chris Bianca 2017-09-21 17:42:09 +01:00
parent 1564973454
commit 902ee98617
14 changed files with 123 additions and 69 deletions

View File

@ -4,12 +4,12 @@ import ModuleBase from './../../utils/ModuleBase';
import ConfirmationResult from './ConfirmationResult';
// providers
import EmailAuthProvider from './providers/Email';
import GoogleAuthProvider from './providers/Google';
import GithubAuthProvider from './providers/Github';
import TwitterAuthProvider from './providers/Twitter';
import FacebookAuthProvider from './providers/Facebook';
import PhoneAuthProvider from './providers/Phone';
import EmailAuthProvider from './providers/EmailAuthProvider';
import GoogleAuthProvider from './providers/GoogleAuthProvider';
import GithubAuthProvider from './providers/GithubAuthProvider';
import TwitterAuthProvider from './providers/TwitterAuthProvider';
import FacebookAuthProvider from './providers/FacebookAuthProvider';
import PhoneAuthProvider from './providers/PhoneAuthProvider';
export default class Auth extends ModuleBase {
static _NAMESPACE = 'auth';
@ -185,7 +185,7 @@ export default class Auth extends ModuleBase {
signInWithCredential(credential: CredentialType): Promise<Object> {
return this._interceptUserValue(
this._native.signInWithCredential(
credential.provider, credential.token, credential.secret,
credential.providerId, credential.token, credential.secret,
),
);
}

View File

@ -1,10 +0,0 @@
export default {
credential(email, password) {
return {
token: email,
secret: password,
provider: 'password',
providerId: 'password',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'password';
export default class EmailAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(email, password) {
return {
token: email,
secret: password,
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -1,10 +0,0 @@
export default {
credential(token) {
return {
token,
secret: '',
provider: 'facebook',
providerId: 'facebook',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'facebook';
export default class FacebookAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(token) {
return {
token,
secret: '',
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -1,10 +0,0 @@
export default {
credential(token) {
return {
token,
secret: '',
provider: 'github',
providerId: 'github',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'github';
export default class GithubAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(token) {
return {
token,
secret: '',
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -1,10 +0,0 @@
export default {
credential(token, secret) {
return {
token,
secret,
provider: 'google',
providerId: 'google',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'google';
export default class GoogleAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(token, secret) {
return {
token,
secret,
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -1,10 +0,0 @@
export default {
credential(verificationId, code) {
return {
token: verificationId,
secret: code,
provider: 'phone',
providerId: 'phone',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'phone';
export default class PhoneAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(verificationId, code) {
return {
token: verificationId,
secret: code,
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -1,10 +0,0 @@
export default {
credential(token, secret) {
return {
token,
secret,
provider: 'twitter',
providerId: 'twitter',
};
},
};

View File

@ -0,0 +1,19 @@
const providerId = 'twitter';
export default class TwitterAuthProvider {
static get PROVIDER_ID() {
return providerId;
}
static credential(token, secret) {
return {
token,
secret,
providerId,
};
}
get providerId() {
return providerId;
}
};

View File

@ -109,7 +109,7 @@ export default class User {
* @param credential
*/
linkWithCredential(credential: CredentialType) {
return this._auth._interceptUserValue(this._auth._native.link(credential.provider, credential.token, credential.secret));
return this._auth._interceptUserValue(this._auth._native.link(credential.providerId, credential.token, credential.secret));
}
/**
@ -126,7 +126,7 @@ export default class User {
* @return {Promise} A promise resolved upon completion
*/
reauthenticateWithCredential(credential: CredentialType) {
return this._auth._interceptUserValue(this._auth._native.reauthenticate(credential.provider, credential.token, credential.secret));
return this._auth._interceptUserValue(this._auth._native.reauthenticate(credential.providerId, credential.token, credential.secret));
}
/**