Skip to content

Commit

Permalink
Merge pull request #1 from OutSystemsExperts/feature/removePatternVal…
Browse files Browse the repository at this point in the history
…idation

Feature/disable pattern validation
  • Loading branch information
cmfsotelo authored Mar 4, 2019
2 parents 31c0b74 + b4ab8bc commit 883c2f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ On your application config.xml file set one, or all, of the following preference
<preference name="SecurePluginDialogCloseLabel" value="CLOSE NOW"/>
```


### Customizing behavior
The plugin default behavior checks if the phone has a password,pin or pattern defined. To deactivate this, change the preference `CheckPattern`.
On your application config.xml file set one, or all, of the following preferences:

```xml
<preference name="CheckPattern" value="false"/>
```

## License

```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "outsystems-secure-device",
"version": "2.0.0.os",
"version": "2.0.0-os2",
"description": "Stops app from running if device is not secure, i.e. it is jailbroken, rooted, or doesn't have a passcode set.",
"cordova": {
"id": "outsystems-secure-device",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="outsystems-secure-device" version="2.0.0.os" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="outsystems-secure-device" version="2.0.0-os2" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>secureDevice</name>
<description>Stops app from running if device is not secure, i.e. it is jailbroken, rooted, or doesn't have a passcode set.</description>
<author>André Vieira</author>
Expand Down
7 changes: 4 additions & 3 deletions src/android/secureDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.outsystemscloud.andrevieira;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.KeyguardManager;
Expand All @@ -42,6 +41,7 @@ public class secureDevice extends CordovaPlugin {
public static final String DIALOG_CLOSE_LABEL = "SecurePluginDialogCloseLabel";
public static final String ROOTED_DEVICE_STRING = "SecurePluginRootedDeviceString";
public static final String NO_LOCK_DEVICE_STRING = "SecurePluginNoLockSafetyString";
public static final String CHECK_PATTERN = "CheckPattern";

CordovaInterface cordova;
CordovaWebView view;
Expand All @@ -62,8 +62,9 @@ public void onResume(boolean multiTasking) {
private void checkDevice() {
boolean _isDeviceRooted = isDeviceRooted();
boolean _isPasscodeSet = doesDeviceHaveSecuritySetup(this.cordova.getActivity());
boolean _checkPattern = this.preferences.getBoolean(CHECK_PATTERN, true);

if (_isDeviceRooted || !_isPasscodeSet) {
if (_isDeviceRooted || (_checkPattern && !_isPasscodeSet)) {
// Remove View
View v = this.view.getView();
if (v != null) {
Expand Down Expand Up @@ -170,7 +171,7 @@ private static boolean isPassOrPinSet(Context context) {
*/
private synchronized void alert(final String message, final String buttonLabel) {
final CordovaInterface cordova = this.cordova;

Runnable runnable = new Runnable() {
public void run() {

Expand Down
5 changes: 3 additions & 2 deletions src/ios/secureDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ - (void) checkDevice
{
BOOL jailbroken = [UIDevice currentDevice].isJB;
LNPasscodeStatus status = [UIDevice currentDevice].passcodeStatus;

if (jailbroken || status == LNPasscodeStatusDisabled || status == LNPasscodeStatusUnknown) {
BOOL checkPattern = ![(NSString* )[self.commandDelegate.settings objectForKey:@"checkpattern"] isEqualToString:@"false"];

if (jailbroken || ( checkPattern && (status == LNPasscodeStatusDisabled || status == LNPasscodeStatusUnknown))) {

NSString* alertMessage = @"This application does not run on a device that is rooted.";
NSString* customAlertCloseButtonText = [self.commandDelegate.settings objectForKey:@"secureplugindialogcloselabel"];
Expand Down

0 comments on commit 883c2f4

Please sign in to comment.