SPRZEDAŻ: 1-800-867-1389
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

Restrict access to admins

Updated: April 15, 2014

The current user is considered to be an administrator when the incoming request includes the master key.

WarningWarning
The master key is an important security credential that is used only by a service administrator. Do not share this secret with anyone, distribute it with your app, or send it over an unencrypted connection.

The following JavaScript backend code detects if the user is an administrator and only allows administrators to delete entries; records deleted by non-administrators are marked as inactive.

function del(id, user, request) {
    if (user.level === 'admin') {
        request.execute();
    } else {
        // The user is not an administrator so mark the 
        // record as inactive instead of deleting it
        var order = {
            id: id,
            hidden: true
        };
        var orderTable = tables.getTable('orders');
        orderTable.update(order, {
            success: function() {
                request.respond(statusCodes.NO_CONTENT);
            }
        });
    }
}

For more information, see the Mobile Services script reference

See Also

Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.
Pokaż:
© 2014 Microsoft