abbr / NodeSSPI

Server-side windows authentication for Node.js
MIT License
157 stars 20 forks source link

TypeError: Cannot read property '0' of null #82

Open H4ppyM4jor opened 4 years ago

H4ppyM4jor commented 4 years ago

Hi! I am trying to implement node-sspi in my reactjs project using react-admin framework. I tested node-sspi in a test express app and it worked just right.

I dont really know how to implement this outside of the express context, but I can not really try either because I get the error "TypeError: Cannot read property '0' of null" by just requiring it.

import nodeSSPI from 'node-sspi'; var util = require('util');

export default {

// called when the user attempts to log in
login: ({ username }) => {
    localStorage.setItem('username', username);
    // accept all username/password combinations
    return Promise.resolve();
},
// called when the user clicks on the logout button
logout: () => {
    localStorage.removeItem('username');
    return Promise.resolve();
},
// called when the API returns an error
checkError: ({ status }) => {
    if (status === 401 || status === 403) {
        localStorage.removeItem('username');
        return Promise.reject();
    }
    return Promise.resolve();
},
// called when the user navigates to a new location, to check for authentication
checkAuth: () => {
    return localStorage.getItem('username')
        ? Promise.resolve()
        : Promise.reject();
},
// called when the user navigates to a new location, to check for permissions / roles
getPermissions: () => Promise.resolve(),

};` nodesspi