[FREE] πŸ”’ Auth Extension- Check if Passcode lock is enabled on a device

Hello everyone
Today I am presenting my Auth extension :smile:


Features
This extension can be used to check if a user has enabled passcode lock on his/her device


Use
If you want to integrate authentication using device lock in your app you can easily do it by using this intent as discovered by @ShanmugaNathan2023

But it has a great limitation well detected by @TIMAI2 that

The extension aims to resolve this issue by checking if the user has a passcode lock set up on his/her device
Then you can use the intent to ask for password lock. Issue Resolved :smile:


Blocks
Function

component_method (5)
This procedure is to be called to get the status of Passcode lock in your device

Events

component_event (2)
This event is called when Passcode lock is setup on the device

component_event (3)
This event is called when Passcode lock is not setup on the device

Note: Passcode lock refers to any type of lock- Pin/Pattern/Fingerprint/Face etc.
Tested on emulator running android 10.


Download the latest aix
io.auth.aix (3.4 KB) 20/09/24


Past Releases
Version 1.0 : io.auth.aix (3.4 KB) 18/09/24


Support the project
If you liked the extension then do make a small funding starting from 0.5$ so I can continue to make such extensions for free.


Usage Policy- Important

I Sarthak Gupta authorize that you can use this extension in any of your projects and even publish them on the Play Store as long as you give me credit like this
Extension by Sarthak Gupta and a link to this post


Regards
Sarthak Gupta @techxsarthak

3 Likes


Spent a while creating this code snippet.
So what it does
When button is clicked it checks if the device has a passcode lock

If passcode is enabled

The app asks for the device credentials. Now the most important question, what happens if the user clicks the back button or the recent apps button. The activity fails and the activity is called again. kind of like a loop. So the user won’t be able to login until the password is entered.
When the password is entered correctly the block in the after activity is executed and the label is changed to success. You can change it and execute any other block obviously

If passcode is disabled

If passcode is disabled then the notifier will show an alert that Lock Disabled

How will you even know if they used your extension in their app and gave you credit ?

Giving credit is important in order to prevent copyright infringement. If you don’t want to give credit then you can donate 4$

Then don’t you think you should mark it paid/credit not free!

Nope its free if you credit me see carefully. Giving credit is always appreciated

Updated the license now you can use the extension for free as long as you give credit me and this post. If you want to support the project then please contribute on the link given above. It will surely motivate me to make more such extensions for free in the future.

Giving credit is compulsory

meaning of free is to get it simple free without giving or doing anything
if giving credit is compulsory how is it free if its take extension give credit its give and take not free!

1 Like

Unsplash images are free also but you should give credit to the author
Giving credit motivates author to create more such projects…

Hope you understand now

i understand we appreciate giving credit but making it compulsory dont make it free
the meaning for free is different
if its compulsory its not free you need to give something(credit)

You don’t want to credit :rofl:

i don’t have something interesting to do becz kodular SDK is not updated :innocent:

1 Like

Yes but as per the license of this extension giving credit is compulsory only if you are releasing the app on app stores.
PS Free doesn’t mean that it has no restrictions

Regards
Sarthak Gupta

1 Like

where to give credit exactly in app or elsewhere ?

Regards
Emperor !!!

You can give it on the description section in the marketplace

if credit is given somewhere but you dont see and give copyright where to appeal

1 Like

Feel free I will not do a strike :grinning: Credit the extension in the description and done

(Maybe Offtopic)
When I send this into ChatGPT:
β€œextension for appinventor: Auth Extension- Check if passcode lock is enabled on a device”

it gives me this java code:

package com.example.auth; // ← Add your package name here

import android.content.Context;
import android.app.KeyguardManager;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.ComponentContainer;

@DesignerComponent(
version = 1,
description = β€œAn extension to check if a device has passcode lock (PIN, pattern, or password) enabled.”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = β€œimages/extension.png”
)
@SimpleObject(external = true)
public class AuthExtension extends AndroidNonvisibleComponent {

private Context context;

// Constructor
public AuthExtension(ComponentContainer container) {
    super(container.$form());
    this.context = container.$context();
}

// Method to check if passcode lock is enabled
@SimpleFunction(description = "Returns true if a passcode lock (PIN, pattern, or password) is enabled on the device.")
public boolean IsPasscodeEnabled() {
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return keyguardManager.isKeyguardSecure();
}

}
Does this work too if you build a aix? I am just curious, because this would be great if you could build extensions in seconds nearly without any knowlegde (like me :smiley: )