Programmatically register users (create users)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hey,

I am super shocked to not find any examples of how to register (create users) through code.  Does anyone have any examples of this or know where I can find documentation that might outline this process?

I am using NopCommerce 2.65.

The end result I want is to create a user, and then authenticate that user, all through code.  

Cheers
11 years ago
Don't be surprised that nopCommerce has very little documentation on development. Anyway, the code itself is a documentation, so digging through the code should give you enough idea. :P

For code related to membership, you can try to have a look at CustomerController, it contains all the 'sample code' there. :)
11 years ago
It's nuts... I love the open'ness of it, just can't believe that there are no documented API's.  Guess I will have to fumble around and try to find what I need
11 years ago
My guess is that I will need to look into a paid solution in order to achieve the level of integration I have been tasked to accomplish.
11 years ago
To create a user manually use:
CustomerService.InsertCustomer( Customer customer)

To authenticate a user either implement IAuthenticationService or use
FormsAuthenticationService
11 years ago
keesjan wrote:
To create a user manually use:
CustomerService.InsertCustomer( Customer customer)

To authenticate a user either implement IAuthenticationService or use
FormsAuthenticationService


That looks promising, but still seems a bit beyond my reach.  Where would you implement that line of code?  Let me explain...

I need to have NC tightly coupled to a parent site.  I was thinking about this approach.

1. Use an HTTPModule on the NC site to check for existence of a custom authentication cookie from the parent site.
2. If cookie does not exist, handle by routing them to the login page of the parent site, or displaying a message of some sort.
3. If cookie does exists, inspect to see if user has already been registered in NC.
4. If user is NOT registered in NC, perform registration for them and log them in.
5. If user IS registered in NC, log them in.

All of that would happen inside the HTTPModule.  Does that seem ok?  Can all I require be done in an HTTPModule?
11 years ago
nokturnal wrote:
To create a user manually use:
CustomerService.InsertCustomer( Customer customer)

To authenticate a user either implement IAuthenticationService or use
FormsAuthenticationService


That looks promising, but still seems a bit beyond my reach.  Where would you implement that line of code?  Let me explain...

I need to have NC tightly coupled to a parent site.  I was thinking about this approach.

1. Use an HTTPModule on the NC site to check for existence of a custom authentication cookie from the parent site.
2. If cookie does not exist, handle by routing them to the login page of the parent site, or displaying a message of some sort.
3. If cookie does exists, inspect to see if user has already been registered in NC.
4. If user is NOT registered in NC, perform registration for them and log them in.
5. If user IS registered in NC, log them in.

All of that would happen inside the HTTPModule.  Does that seem ok?  Can all I require be done in an HTTPModule?


Hmmm... Why do you want to use HTTP Module? What program is your parent site running on?

If I were to do it, I would:

1. Create a plugin that exposes the functionality of ICustomerService as a REST-ful service.
2. Call the REST service from the parent site.
11 years ago
nokturnal wrote:

1. Use an HTTPModule on the NC site to check for existence of a custom authentication cookie from the parent site.
2. If cookie does not exist, handle by routing them to the login page of the parent site, or displaying a message of some sort.
3. If cookie does exists, inspect to see if user has already been registered in NC.
4. If user is NOT registered in NC, perform registration for them and log them in.
5. If user IS registered in NC, log them in.

All of that would happen inside the HTTPModule.  Does that seem ok?  Can all I require be done in an HTTPModule?


Sounds complicated. I think you should look at how external authentication is implemented in nop (OpenId,Facbook, Twitter)
11 years ago
I cannot expose the NC site in any way unless the users (customers) come from the parent site.

I was hoping to simply wrap all that logic up into a single HTTPModule.  That way it handles the security (all customers must come from the parent site) and the customer create and login functionality.

I originally thought about using a webservice type model, but though the HTTPModule method might be better.  Thoughts?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.