0.1.12 • Published 7 years ago

smart-access v0.1.12

Weekly downloads
2
License
ISC
Repository
-
Last release
7 years ago

Smart Access

Managing user access list in a smarter way based on smart-mysql-cache.

How To Install :

npm install smart-access

How To Connect:

Fields user , storage , debugging is required.

For Example :

let collection = {
    group: {
        attributes: [
            {name: 'id'},
            {name: 'name'}
        ]
    },
    action: {
        attributes: [
            {name: 'id'},
            {name: 'name'},
            {name: 'order'},
            {name: 'caption'}
        ]
    },
    access: {
        attributes: [
            {name: 'id'},
            {name: 'group', collection:'group'},
            {name: 'action', collection:'action'},
            {name: 'status'}
        ]
    },
    user: {
        attributes: [
            {name: 'group', collection:'group'},
            {name: 'id'},
            {name: 'username'},
            {name: 'password'},
            {name: 'birthday'},
            {name: 'name'},
            {name: 'surname'}
        ]
    }
};
var {cache} = require("smart-mysql-cache");
var db = new cache({collection});

var access_list = require("smart-access");
var user = null;
function login(username, password){
    let user = db.collection('user').find({username, password});
    var access = new access_list(user, db);
}
function granted(name, order){
    if(user != null){
        return user.granted(name, order);
    }
    return false;
}

Granted Method :

Check access user by collection name and operation order.

access.granted(collection_name , operation_order)

For Example :

if(access.granted("bus","add")){
    console.log("ok");
}

Allow Method:

Allow access user by collection name and operation order

access.allow(collection_name , operation_order);

For Example :

access.allow("bus","remove");
if(access.granted("bus","remove")){
    console.log("access granted.");
}
// always log "access granted."

Deny Method :

Deny access user by collection name and operation order

access.deny(collection_name , operation_order);

For Example :

access.deny("bus","remove");
if(access.granted("bus","remove")){
    console.log("access granted.");
}
// never log enything
0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago