This question has been flagged
1 Reply
3690 Views

Updated

I wanted to create a customized sign in page that would allow 2 type of customer to create an account with different roles.

It turns out that even when I use the inbuilt auth_signup module, the user_navbar is not visible as well. 

I then found out that you actually need to add the website.user_navbar under the group's view if using auth_signup module.

But my problem still remains that my user still cannot view the website.user_navbar and nagivate to the respective application when login. 



BR,
Gavin

Avatar
Discard
Author Best Answer

There a 2 discoveries I made:

1) if auth_signup is ever used, you need to manually add the website.user_navbar to the view of the group that the user is created. For signup users using the auth_signup process, the user will be assigned to the  group_portal user group. So adding the nav_bar there, would allow the black navigation bar to appear, allow the user to navigate to other modules, e.g. customer portal

) The other discovery I made was either 2 accounts Hr.employee (and the rest of the groups) or user_portal (with website.navbar) will be able to see the navigation bar and navigate to the respective custom modules I create. Now if I would copy and clone either the account for my customized signup user. It would not work, and I could figure out why? As a part of my work around, my signup process includes assign the user with group_portal and then a customized group type that I intended for the customer.


    @http.route('/market/signup/customer/', auth='public', website=True)
def customer_sign_up(self, **kw):
# GET Request
if http.request.httprequest.method == 'GET':
return http.request.render('elm.customer_sign_up')
# POST Request
if http.request.httprequest.method == 'POST':
print "POST"
self.do_signup_customer(http.request.params)
return "Customer user created"
    def do_signup_customer(self, values):
# Retrieve all fields from values
email = values.get('login')
name = values.get('name')
password = values.get('password')
confirm_password = values.get('confirm_password')
# Check if password and confirmation match
assert password == confirm_password, "Passwords do not match; please retype them."
# Check login field for valid email
assert re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email), "%s is not a valid email address." % email
# Check if login(email) exist
count = http.request.env['res.users'].search_count([['login', '=', email]])
assert count == 0, "User already exist, please try reset password"
# create the user if all assertion passed
 
# Get the reference of customer group and portal group
customer = http.request.env.ref('elm.group_customer')
portal = http.request.env.ref('base.group_portal')

# Create User
http.request.env['res.users'].sudo().create({
'name': name,
'login': email,
'password': password,
'groups_id': [(6, 0, [customer.id, portal.id])],
})



Avatar
Discard