Hi, I'm looking into how to fix my issue. Can you help me?
* Summary
I tried OAuth tutorial followed by "oauth-advanced sample". I got an error after I clicked login button.
https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/oauth-advanced
* Steps to Reproduce
$ mkdir oauth-sample $ cd oauth-sample $ npm install -g yo $ npm install -g apigeetool $ npm install generator-oauth-auth-code-grant-sample -g $ yo oauth-auth-code-grant-sample // Followed the prompts // Open http://myorg-test.apigee.net/web // Click Login with Apigee Example Auth Button // Enter Email address and Password. Click Login Button.
* Expected
Results Redirect to the redirect url.
* Actual Results The following error occurred.
TypeError: org.mozilla.javascript.Undefined@11005018 is not a function, it is undefined. at /organization/environment/api/routes/login.js:162 at /organization/environment/api/routes/login.js:60 at handle (/organization/environment/api/node_modules/express/lib/router/layer.js:95)
* Note
I posted the same issue on github.
https://github.com/apigee/api-platform-samples/issues/93
Solved! Go to Solution.
Hi @zono Looks like the issue is with the validator().
Try the below to proceed further. More info here https://github.com/chriso/validator.js
validateLoginForm = function (username, password) { var validator = require('validator') // var errors = []; //validator.error = function(msg) { errors.push(msg); }; validator.isEmail(username); validator.isLength(password,{min:1, max: 50}); //v.check(username, 'A valid email address is required').len(1, 50); //v.check(password, 'Password is required').len(1, 50); //return errors; };
Hi @zono Looks like the issue is with the validator().
Try the below to proceed further. More info here https://github.com/chriso/validator.js
validateLoginForm = function (username, password) { var validator = require('validator') // var errors = []; //validator.error = function(msg) { errors.push(msg); }; validator.isEmail(username); validator.isLength(password,{min:1, max: 50}); //v.check(username, 'A valid email address is required').len(1, 50); //v.check(password, 'Password is required').len(1, 50); //return errors; };
@Maruti Chand Thank you. I will try it.
@Maruti Chand You are awesome. I changed the validation method then it worked.
I found that I could update the two js files on Apigee Edge. That's great. (but I think the deployment is very slow)
* routes/registration.js
validateForm = function (title, firstname, lastname, email, password, verifypassword) { var errors = []; return errors;
};
* routes/login.js
validateLoginForm = function (username, password) { var errors = []; return errors; };
Thanks @Maruti Chand, got past that one now in the user-mgmt-v1 I get: Execution of pw-hashing failed with error: Javascript runtime error: "TypeError: Cannot call method "split" of null. (pw-hashing.js:49)" THis is because it's expecting KVM data and it's null, which could be because of the login I assume, but I added the the webserver-product to my app
@Maruti Chand Ok nevermind I was confused that the "register" was an apigee register, instead it adds a user with the user-mgmt-v1 api so it's a user to that "external" system, you aren't adding a new developer to apigee.
Hi,
For me , when I try to run the command:
yo oauth-auth-code-grant-sample
I am getting the following error:
Error oauth-auth-code-grant-sample
primordials is not defined
Hope you can give me a light or clue to fix the error.
Regards,
were you able to resolve the error?