Deluge- how to prevent a user who is already signed in from signing in again - zoho

I have written a simple deluge script for a Sign In app.
Is there a way to prevent a user who is already signed in from signing in again?
Likewise, is there a way to prevent a user who is already signed out from signing out again?
What I have below populates the Staus with either Sign In or Sign Out but the user can manually override this is and sign In/Out twice
var = Sign_in_out[UserName == input.UserName] sort by Added_Time Desc;
if(var.Status == "Sign In")
{
Status.select("Sign Out");
}
else if(var.Status == "Sign Out")
{
Status.select("Sign In");
}
else
{
Status.select("Sign In");
}

In Zoho-Creator, the login state of a user can be checked with either zoho.loginuser or zoho.loginuserid. If either of these is null then the user is logged out. If they are not-null, then the user is logged in.
Deluge probably has the same behavior in other Zoho tools, but give it a try in-order to verify the behavior.
Example:
if (zoho.loginuserid == null)
{
info "Login-Status: Signed-Out:[" + zoho.loginuserid + "]";
}
else
{
info "Login-Status: Signed-In:[" + zoho.loginuserid + "]";
}
10-26-2022, Additional note after comments:
Try automatically refreshing the page. Here is a few example methods. These methods should work for Pages, Forms and Reports.
Example:
// Refresh a page using a full path url
openUrl("https://<zoho-url-path/#Page:<page-name>", "same window");
// Refresh a form with Zoho short path
openUrl("#Form:<login-form-name>", "same window");

Related

Xamarin.Forms android check whether user clicked Deny and Don't ask again

In my xamarin.forms app. I am using xamarin.Essentials to check and request permissions. I can check whether a permission is granted or not in android. The problem I am facing is when user clicks "Deny and Don't ask again" the status still shows Denied. How can we know whether user selected Deny and Dont ask so that I can show a warning message according to that. Any help is appreciated.
For check and request permission in Xamarin.Forms you could also use the plugin Permission.Plugin from nuget .
The option Deny and Don't ask again will only appear when you deny the request the second time . However , there is no such a specific status to tag it .
As a workaround , we could define a custom property to save the time that we deny .
int DenyCount = 0;
private async void FabOnClick(object sender, EventArgs eventArgs)
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission>();
if (status != PermissionStatus.Granted)
{
if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
{
//await DisplayAlert("Need location", "Gunna need that location", "OK");
DenyCount++;
if(DenyCount>=2)
{
//...
}
}
status = await CrossPermissions.Current.RequestPermissionAsync<LocationPermission>();
}
if (status == PermissionStatus.Granted)
{
//Query permission
DenyCount = 0; // reset the value of DenyCount
}
else if (status == PermissionStatus.Restricted)
{
//location denied
}
}
Xamarin.Essentials provides a method for detecting whether the user has clicked to "don't ask again". You can check if a dialog should be shown by calling ShouldShowRationale:
var canAskAgain = Xamarin.Essentials.Permissions.ShouldShowRationale<Permission_Type>();
var didCheckDontAskAgain = !canAskAgain;
If this is true, that means the user did not click "Deny and Don't Ask Again".
Also, note that on Android 12 (and maybe 11, not sure), if you click "Deny" mulitple times, Android assumes that you mean "Don't ask again". The user may never explicitly check that option, but it may be inferred by Android.

Cannot navigate to page which was called once before

Short intro into my application's-logic:
My application is using a REST-Api and needs a token for all requests but a specific one (let's call it "pairing-page").
Before I navigate to any of my pages I'm checking the target location. If my target is the page where I'm requesting the token, no checking for a existing token is made.
For every other page a token is necessary. If no token exists the user should navigate back to the "pairing-page".
My start-Page is my paring-page.
What's the problem?:
When starting the app (pairing-page) and getting the token and navigating to the 2nd page - let's call it "overview" - everything is ok. The overview has a button which calls a method that removes my token and navigates back to the pairing-page. That's working as well.
Now the interesting part:
When I try to pair & navigate to the overview again (2nd time), no navigation is done. By this I mean my overview is not popping up.
I'm using Xamarin's Shell Navigation and overriding the OnNavigating-Method.
Code:
protected override void OnNavigating(ShellNavigatingEventArgs args)
{
// check if BearerToken exist. If so, navigate to Overview
if (args.Target.Location.ToString() != "//Admission.Event.Pair"
&& args.Target.Location.ToString() != "Admission.Event.Pair")
{
App app = App.Current as App;
string bearerToken = RestServiceCalls.GetBearerToken(app._dependencyService);
// if a the token is missing call the Pairing-Page
if (string.IsNullOrEmpty(bearerToken)
|| string.IsNullOrWhiteSpace(bearerToken))
{
Device.BeginInvokeOnMainThread(async () => { await NavigateToPageAsync("Admission.Event.Pair"); });
return;
}
}
base.OnNavigating(args);
}
async Task NavigateToPageAsync(object pageName, bool animate = true)
{
await Xamarin.Forms.Shell.Current.GoToAsync($"{pageName.ToString()}", animate);
Xamarin.Forms.Shell.Current.FlyoutIsPresented = false;
}
Let's take a look into the args:
Application start, pairing-page:
args.Target.Location: //Admission.Event.Pair
args.Current.Location: null
The Pairing-Page is popping up, everything is ok.
Click on the Button which processes getting a token and after that navigating to the overview:
args.Target.Location: Admission.Event
args.Current.Location: //Admission.Event.Pair
The overview page is popping up, everything is ok. Got a valid token as well.
Click on Button which processes removing the token and navigating to the pairing-page:
args.Target.Location: Admission.Event.Pair
args.Current.Location: //Admission.Event.Pair/Admission.Event
The token is removed correctly (is null) and the pairing-page pops up. Everything is ok.
Now the problem occurs:
When I'm now trying to get a token and navigate to the overview again my args have this content and my overview wont show up:
args.Target.Location: Admission.Event
args.Current.Location: //Admission.Event.Pair/Admission.Event/Admission.Event.Pair
Any idea about that?
My first thought was it might be an issue with the target-location.
Like I said in my comment:
For me I could simple use:
if(shell != null){
INavigation navigation = shell.Navigation;
navigation.PopToRootAsync();
}

Facebook SDK inside iOS app extension cannot find logged in user?

I've created a sample app Share extension. Followed the Apple guides, which means my project consists of a main app and a "share extension" target.
I've setup my Facebook SDK inside the main app, since the app's settings has some FB login/status functionality. It works well according to expectation: users can login and do some shares.
But I also want the logged-in user to be available to the extension target itself. When my extension comes up (in any app), I check Facebook's login status in viewDidLoad:, and it outputs "not logged in":
if ([FBSDKAccessToken currentAccessToken]) {
NSLog(#"logged in");
} else {
NSLog(#"not logged in");
}
The same code outputs "logged in" if called from within the main app. I suspect it has something to do with the fact that the extension target has a different bundle ID that looks like this: .suffix and I guess FB SDK is trying to read the user ID off the keychain cache, but maybe it's reading it off the wrong keychain due to the different bundle IDs... But it could be other reasons as well I guess.
Any idea how to keep Facebook SDK "logged in" inside the extension after the login itself occurred in the containing main app?
I have the exact same problem, as I develop a Message Extension App with a Facebook Login.
To solve the problem, I put the Login Button in the App and use the shared UserDefaults (with a group name) to store a property :
/*
* Get / sets if is FB connected (because we can't use FB SDK in Extension)
*/
public var isFacebookConnected : Bool {
get {
// Getting Bool from Shared UserDefaults
let defaults : NSUserDefaults = NSUserDefaults.init(suiteName: "MY_GROUP_NAME")!
let isFBConnected : Bool? = defaults.boolForKey("IsFacebookConnected")
if isFBConnected == nil {
return false
} else {
return isFBConnected!
}
}
set {
// Setting in UserDefaults
let defaults : NSUserDefaults = NSUserDefaults.init(suiteName: "MY_GROUP_NAME")!
defaults.setBool(newValue, forKey: "IsFacebookConnected")
defaults.synchronize()
}
}
This property is accessed from the App or from the Extension.
Then, in my Login / Logout methods I add :
//FBLogin
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if let error = error {
print(error.localizedDescription)
return
}
if result.isCancelled
{
return
}
// Set in Shared UserDefaults if connected / not connected
ConfigManager.sharedInstance.isFacebookConnected = true
...
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
// OK, keeping track
ConfigManager.sharedInstance.isFacebookConnected = false
}
Then, I keep track of my flag when login / logout.
Warning : this method is not bullet proof as I can't know if Facebook has been uninstalled, but it is robust enough for me.
I believe you'll need to take advantage of Keychain sharing capability in the app and extension to solve this.
https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps

Catching error with Usermanager.getUser() in Google Apps Script

I am working withing Google Spreadsheet creating a script file that has to deal with obtaining user information on my Google Apps Domain. I have admin rights and the Provisioning API is enabled. In my code, I am trying to catch the error when looking up a specific user on a Google Apps Domain (user not found) and instead display a message and continuing on with the rest of the program. The try-catch statement I have here works when there is no error on the user. However, when there is an error on retrieving the user, I get the error: "Unexpected exception upon serializing continuation". Here is my code:
function testOfDomainAccess() {
var i=0;
var anArray= ["johhn.smith", "susan.que]; //john smith misspelled
var user;
for (i=0; i < anArray.length; ++i)
{
Logger.log("\nThe current user being processed is " + anArray[i]);
try
{
user = UserManager.getUser (anArray [i]);
}
catch (error)
{
Browser.msgBox("Error: " + error.name + "\n Check your spreadsheet for misspellings of " + anArray[i] + " and We will continue to the next user.");
user = null;
}
if (user != null) {
//Perform tasks
}
else
Logger.log("User not found in domain. Moving on the next item in the array.");
}
If anyone can help with this problem I would greatly appreciate it. I am new to Google Apps Script and Provisioning API. Thanks!
It looks like the same bug reported at http://code.google.com/p/google-apps-script-issues/issues/detail?id=980.
The workaround is to replace the Browser.msgBox() call with Logger.log() and your script should run as expected.

How to show different pages when app launches time in windows phone 7?

When app launches time need to show the registration page.once user registered it shouldn't goes to registration page need to go log in page.
How to achieve this?
You can navigate to the start page of a Windows Phone app from code.
Remove the "DefaultTask" entry from the WMAppManifest
Remove the NavigationPage attribute from the "DefaultTask" in WMAppManifest, and in the Launching event of your app use the something like the example below to navigate to the page of choice upon launch.
private void Application_Launching(object sender, LaunchingEventArgs e)
{
if (registered)
{
((App)Application.Current).RootFrame.Navigate(new Uri("/<your start page>.xaml", UriKind.Relative));
}
else
{
((App)Application.Current).RootFrame.Navigate(new Uri("/<your registration page>.xaml", UriKind.Relative));
}
}
You just have to decide how you want to determine that someone already registered.
I guess you haven't put a lot of thought to this, the setup is pretty easy! When a user registers you could set a variable in the settings defining that a user already has registered. When the application starts, evaluate this setting and if the user registered you show the register-page, otherwise the login-page. Example:
//After (succesful) registration
Properties.Settings.Default.HasRegistered = true;
Properties.Settings.Default.Save();
//Check the value
var hasRegistered = Properties.Settings.Default.HasRegistered;
if(hasRegistered)
//show Login
else
//show Registration
You can also use the IsolatedStorageSettings.ApplcationSettings to do this. The code below is just sample code, you'll have to provide validation if the settings already exist on the first startup of the app and set a default value 'false' for the setting if no registration has occured yet.
//After registration
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("HasRegistered"))
settings["HasRegistered"] = true;
settings.Save();
//Check value
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("HasRegistered"))
{
var registered = bool.Parse(settings["HasRegistered"]);
if(registered)
//show login
else
//show registration
}
Hope this helps!

Resources