有没有人将auth0-lock-passwordless整合到离子2+混合应用中?Auth0无密码锁定离子2+应用
我不知道如何处理的回调URL
我有此代码为角服务,称为auth.service.ts:
import {Storage} from '@ionic/storage';
import {AuthHttp, JwtHelper, tokenNotExpired} from 'angular2-jwt';
import {Injectable} from '@angular/core';
import Auth0LockPasswordless from 'auth0-lock-passwordless'
@Injectable()
export class AuthService {
private clientID = "XXXXXXXXXXX";
private domain = "myapp.eu.auth0.com";
jwtHelper: JwtHelper = new JwtHelper();
lock: any;
local: Storage = new Storage()
user: Object;
constructor(private authHttp: AuthHttp) {
// If there is a profile saved in local storage
this.lock = new Auth0LockPasswordless (this.clientID, this.domain)
this.local.ready().then(() => {
this.local.get('profile').then(profile => {
this.user = JSON.parse(profile);
})
}).catch(error => {
console.log(error);
});
}
public authenticated() {
// Check if there's an unexpired JWT
return tokenNotExpired();
}
public login() {
// Show the Auth0 Lock widget
this.lock.emailcode({
responseType: 'code',
authParams: {
scope: 'openid email',
device: 'Mobile device'
}
}, (err, profile, token, accessToken, state, refreshToken) => {
// CALLBACK CODE
if (err) {
// IF THERE'S AN ERROR, THIS CODE IS EXECUTED
alert(JSON.stringify(err))
} else {
// IF EVERYTHING GOES FINE, THIS CODE IS NEVER CALLED, IT IS SENT TO A CALLBACK URL
this.local.ready().then(() => {
alert("profile: " + JSON.stringify(profile))
alert("id_token: " + JSON.stringify(token))
alert("refresh_token: " + JSON.stringify(refreshToken))
alert("state: " + JSON.stringify(state))
alert("err: " + JSON.stringify(err))
this.local.set('profile', JSON.stringify(profile));
this.local.set('id_token', token);
this.local.set('refresh_token', refreshToken);
this.user = profile;
})
}
});
}
public logout() {
this.local.ready().then(() => {
this.local.remove('profile');
this.local.remove('id_token');
this.local.remove('refresh_token');
this.user = null;
})
}
}
我试图设置Auth0应用作为本地和单个网页,没有成功。
下面是从那里我得到了我的灵感来自于一些网站:
要处理我想我可以用离子Deeplinks回调,但去之前我想确认这是正确的方式。
一个问题是:Deeplinks和Cordova自定义URL插件有什么区别?
显示代码plis – Ivaro18
添加代码和详细信息 –