2.Vue access to enterprise micro-letter Code and the Code sent to verify the background

1. The following code is written in the page configuration request enterprise micro-letter

Mounted () {
     // Get micro-channel request Code 
    the let code = the this $ route.query.code;.
     IF (code) {
       the this .loginwx (code); 
    } 
} 
the async loginwx (code) { 
// Code to send backend do verify the await
the this . $ store.dispatch ({ of the type: "App / loginwx" , the Data: { AuthProvider: "EnterpriseWechat" , // AbpZero Auth third-party login name their own definition (needs to be consistent with the definition of the back-end) providerKey: code, providerAccessCode: code } }); location.reload (); }

 2. app.ts increase app / loginwx action

loginwx the async (Content: the ActionContext <AppState, the any> , payload: the any) { 
// ABP has achieved third place visit our direct this method can
/ API / TokenAuth / ExternalAuthenticate

the let REP = the await ajax.post ( "/ API / TokenAuth / ExternalAuthenticate " , payload.data);
var tokenExpireDate = payload.data.rememberMe ? (new Date(new Date().getTime() + 1000 * rep.data.result.expireInSeconds)) : undefined; 

Util.abp.auth.setToken(rep.data.result.accessToken, tokenExpireDate);

Util.abp.utils.setCookieValue(appconst.authorization.encrptedAuthTokenName, rep.data.result.encryptedAccessToken, tokenExpireDate, Util.abp.appPath)
},

We had a good front-end finished.

Guess you like

Origin www.cnblogs.com/liaoyd/p/11506091.html