-2
アダプタベースの認証を使用してアプリケーションを開発しています。IBM Mobilefirst Platform Foundation 7.1でセッションをクリアするにはどうすればよいですか?
user1がログアウトしてuser2がログインした後、「user already exists、please logout」のようなエラーが発生していることがわかりました。
この問題を解決するには、user2がログインしようとしたときにMobileFirst Serverセッションをクリアする必要があります。
アプリケーションのConfig.xml
<staticResources>
<resource id="subscribeServlet" securityTest="SubscribeServlet">
<urlPatterns>/subscribeSMS*;/receiveSMS*;/ussd*</urlPatterns>
</resource>
</staticResources>
<securityTests>
<mobileSecurityTest name="PushApplications">
<testUser realm="pushAppRealm"/>
<testDeviceId provisioningType="none"/>
</mobileSecurityTest>
<customSecurityTest name="SubscribeServlet">
<test realm="SubscribeServlet" isInternalUserID="true"/>
</customSecurityTest>
</securityTests>
<realms>
<realm name="SampleAppRealm" loginModule="StrongDummy">
<className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
</realm>
<realm name="SubscribeServlet" loginModule="rejectAll">
<className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm>
<realm loginModule="PushAppLoginModule" name="pushAppRealm">
<className>com.worklight.integration.auth.AdapterAuthenticator</className>
<parameter name="login-function" value="pushNotificationAdapter.onAuthRequired"/>
<parameter name="logout-function" value="pushNotificationAdapter.onLogout"/>
</realm>
</realms>
<loginModules>
<loginModule name="StrongDummy" expirationInSeconds="3600">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
<loginModule name="requireLogin" expirationInSeconds="3600">
<className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
</loginModule>
<loginModule name="rejectAll" expirationInSeconds="3600">
<className>com.worklight.core.auth.ext.RejectingLoginModule</className>
</loginModule>
<loginModule name="PushAppLoginModule" >
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
</loginModules>
Appliation Descriptor.xml
MobileFirst Serverセッションをクリアする方法は何ですか
<displayName>pushNotification</displayName> <description>pushNotification</description> <author> <name>application's author</name> <email>application author's e-mail</email> <homepage>http://mycompany.com</homepage> <copyright>Copyright My Company</copyright> </author> <mainFile>index.html</mainFile> <features/> <targetCategory>UNDEFINED</targetCategory> <licenseAppType>APPLICATION</licenseAppType> <thumbnailImage>common/images/thumbnail.png</thumbnailImage> <userIdentityRealms>pushAppRealm</userIdentityRealms> <accessTokenExpiration>3600</accessTokenExpiration> <android version="1.0"> <worklightSettings include="false"/> <pushSender key="AIzaSyAxazrxBZ1tDQWhuGRsQR3DLiPzfm-O-V8" senderId="1019918790021"/> <security> <encryptWebResources enabled="false"/> <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/> <publicSigningKey/> <packageName/> </security> </android>
たときに、ログインユーザーがボタンをクリック
function wlCommonInit() {
\t \t WL.Client.connect({
\t \t \t onSuccess : onConnectSuccess,
\t \t \t onFailure : onConnectFailure
\t \t });
\t \t function onConnectSuccess() {
\t \t \t alert(WL.Client.Push.isSubscribed("myPushh"))
\t \t }
\t \t function onConnectFailure() {
\t \t \t alert("connection failed")
\t \t }
\t \t
\t }
$(document).on('click', '#btnSubmitLogin', function() {
\t var civilId=document.getElementById("txtMbrIdLogin").value;
\t
\t if(WL.Client.isUserAuthenticated("pushAppRealm")==false){
\t \t if(WL.Client.getUserName("pushAppRealm")== null){
\t \t alert("user not authenticated");
\t \t if(WL.Client.Push.isSubscribed("myPushh")){
\t \t \t alert("user subscribed");
\t \t WL.Client.Push.unsubscribe("myPushh", {
\t \t onSuccess: function() {
\t \t \t alert("unsubscribe success");
\t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t },
\t \t onFailure: function() {
\t \t \t alert("unsubscribe fail")
\t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t }
\t \t });
\t }
\t \t else{
\t \t \t alert("user not subscribed");
\t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t }
\t \t }else{
\t \t \t WL.Client.logout('pushAppRealm', { onSuccess: function() {
\t alert("logout"); if(WL.Client.Push.isSubscribed("myPushh")){
\t \t \t alert("user subscribed");
\t \t WL.Client.Push.unsubscribe("myPushh", {
\t \t onSuccess: function() {
\t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t },
\t \t onFailure: function() {
\t \t \t alert("unsubscribe fail")
\t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t }
\t \t });
\t }else{
\t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t } }, onFailure:function() {
\t alert("Unable to logout");
\t } });
\t // callSubmitAuthentication(civilId,"from QLM"); \t
\t \t }
\t }
\t \t else if(WL.Client.isUserAuthenticated("pushAppRealm")==true){
\t \t \t if(WL.Client.Push.isSubscribed("myPushh")){
\t \t \t WL.Client.Push.unsubscribe("myPushh", {
\t \t \t onSuccess: function() {
\t \t \t \t WL.Client.logout('pushAppRealm', { onSuccess: function() {
\t \t \t \t alert("logout"); callSubmitAuthentication();
\t \t \t \t }, onFailure:function() {
\t \t \t \t alert("Unable to logout");
\t \t \t \t }});
\t \t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t \t },
\t \t \t onFailure: function() {
\t \t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t \t }
\t \t \t });
\t \t }else{
\t \t \t \t \t callSubmitAuthentication(civilId,"from QLM");
\t \t \t \t }
\t \t \t }
});
Logout APIを使用している場合は、この問題が発生するはずです。 Logout APIを使用して実際にログアウトしていますか? –
はい、ログアウトAPIを使用しています –
WL.Serverを試すことができますか?setActiveUser( "realmname"、null); WL.Server.setActiveUser( "realmname"、username)を実行する前に? WL.Server.setActiveUser( "realmname"、username)がループしている場合は –