GlideUser user.authenticate inconsistent behaviour

arshadehsan
Tera Contributor

I need to understand why the authenticate function returns false even when the user log in with the right credentials. My 'Installation Exits' script looks like this:

gs.include("PrototypeServer");

var LoginREST = Class.create();
LoginREST.prototype = {
	initialize : function() {
	},

	process : function() {
		// the request is passed in as a global
		var userName = request.getParameter("user_name");
		
		var userPassword = request.getParameter("user_password");

		var user = GlideUser;
		var authed = user.authenticate(userName, userPassword);
		gs.log('2 - User ' + userName + ' Authentication check : ' + authed,'LoginREST');
		if (authed) {
			var eternalCall = new NetceteraLogin().consumeExternalWS(userName);
			return user.getUser(userName);
		}

		this.loginFailed();

		return "login.failed";
	},

	loginFailed : function() {
		gs.log('5 - loginFailed called','LoginREST');
		if (GlideController.exists("glide.ldap.error.connection")) {
			var ldapConnError = GlideController.getGlobal("glide.ldap.error.connection");
			if ( GlideStringUtil.notNil(ldapConnError) )
				GlideSession.get().addErrorMessage(ldapConnError);
		} else {
			var message = GlideSysMessage.format("login_invalid");
			GlideSession.get().addErrorMessage(message);
		}

	}

}

 

0 REPLIES 0