让用户登录办公室365 [英] Keep user sign in In office 365

查看:50
本文介绍了让用户登录办公室365的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hello Developers我正在使用Xamarin Forms我有两种方法来验证用户 :$


1:用户输入用户名和密码 



2:用户可以使用他们的Office 365帐户进行身份验证。


当用户输入用户名和密码时,第一种方法
 并检查用户名和密码是否存在... 

i执行此操作:


< pre class ="prettyprint"> app.Properties [" logged"] =" true" ;;


同样适用于Office 但我总是回到Authentification页面 
$


这是App.cs 


 if(this.Properties.ContainsKey(" logged")&& Application.Current.Properties [" ; logs"]。ToString()==" true")
{
MainPage = new NavigationPage(new MasterMenuPage());
}
else
{
if(this.Properties.ContainsKey(" currentConfig"))
{
MainPage = new NavigationPage(new AuthentificationPage( ));
}
else
{
MainPage = new NavigationPage(new ChoixEcole());
}
}







解决方案

请使用`插入代码编辑器中的"阻止"选项可将代码粘贴到您的帖子中。没有它你的代码很难阅读。


我强烈建议你自己调试。由于您的代码是"转到身份验证页面",在进行此确定的代码行上放置一个断点。然后运行你的代码并评估表达式,以了解为什么它会沿着这个
路径而不是你预期的路径。鉴于您发布的代码,问题在于您的`if`语句,因此这是您要评估的行。 


我的运行理论是逻辑AND的左侧是是的,所以它落到了'else`区块。在调试器中查看此内容将使其立即清除,如果发生这种情况。我认为,这个问题是一个范围问题。您在第一个代码块中使用`app.Properties`
。在逻辑AND左侧的`if`语句中,您使用的是`this.Properties`,但在右侧,您正在使用`Application.Current.Properties`。我怀疑`this`和`Application.Current`是不一样的,所以你看
看错了属性。


另外,我建议你忘了这个字符串比较的东西你正在处理一个布尔值,所以除非`Properties`被定义为`Dictionary< string,string>`,否则只需使用一个布尔值(`true`或`false`)。它消除了字符串比较
stuff。


Hello Developers I'm using Xamarin Forms I have two method to authenticate user  :

1 : the user enter username and password 

2 : the user can authenticate with their Office 365 account .

for the first method when the user enter his username and password  and check if username and password existe ... 
i do this :

                                    app.Properties["logged"] = "true";

same for Office  but i always go back to the Authentification Page 

this is the App.cs 

           if (this.Properties.ContainsKey("logged") && Application.Current.Properties["logged"].ToString() == "true")
           {
               MainPage = new NavigationPage(new MasterMenuPage());
           }
           else
           {
               if (this.Properties.ContainsKey("currentConfig"))
               {
                   MainPage = new NavigationPage(new AuthentificationPage());
               }
               else
               {
                   MainPage = new NavigationPage(new ChoixEcole());
               }
           }



解决方案

Please use the `Insert Code Block` option in the editor to paste code into your posts. Your code is hard to read without it.

I strongly recommend you debug this yourself. Since your code is "going to the auth page" put a breakpoint on the line of code that makes this determination. Then run your code and evaluate the expression to understand why it is going down this path instead of your expected path. Given the code you posted the issue is with your `if` statement so that is the line you want to evaluate. 

My running theory is that the left side of your logical AND is false so it falls to the `else` block. Viewing this in the debugger will make it immediately clear if this is happening. The problem, I believe, is a scoping issue. You are using `app.Properties` in the first code block. In your `if` statement on the left side of the logical AND you're using `this.Properties` but on the right side you're using `Application.Current.Properties`. I suspect `this` and `Application.Current` aren't the same thing so you're looking at the wrong properties.

Also, I recommend that you forget this string comparison stuff. You're dealing with a boolean so unless `Properties` is defined to be a `Dictionary<string, string>` then simply use a boolean value (`true` or `false`). It eliminates the string comparison stuff.


这篇关于让用户登录办公室365的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆