0
votes

Recently,i was started working on Loopback and i am facing one issue in project. In my project we are using built in loopback User.login functionality that's provide a feature to login our site by providing email and password, password is mandatory field. So, problem is password field, i want to provide login functionality without using password in place of password i want to check facebook id, i do not understand how to use built in loopback User.login model with two parameter one is email and second is facebook id instead of password. In my case i am getting email id and some basic information from facebook by using javascript (i am not using facebook-passport package), So instead of password i want to pass only email and facebook id in User.login model. My project is rest api and i am storing user data also in local storage, So i want to create costume login functionality.

1

1 Answers

0
votes

Create a custom function in your model and then define it as a remote method by path /login.

user.MyLogin = function(data, cb){
// data.username
// data.password
// data.facebookId
};

user.remoteMethod(
  'MyLogin',
  {
   accepts: [{
                arg: 'data',
                type: 'object',
                required: true,
                http: {
                    source: 'body'
                }
            }],
            returns: {
                arg: 'result',
                type: 'object',
                root: true
            },
            http: {
                path: "/login",
                verb: 'post',
                status: 201
            }
  }
);