You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							54 lines
						
					
					
						
							2.1 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							54 lines
						
					
					
						
							2.1 KiB
						
					
					
				
								"""Microsoft azure login"""
							 | 
						|
								# -*- coding: utf-8 -*-
							 | 
						|
								#############################################################################
							 | 
						|
								#
							 | 
						|
								#    Cybrosys Technologies Pvt. Ltd.
							 | 
						|
								#
							 | 
						|
								#    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
							 | 
						|
								#    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
							 | 
						|
								#
							 | 
						|
								#    You can modify it under the terms of the GNU LESSER
							 | 
						|
								#    GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
							 | 
						|
								#
							 | 
						|
								#    This program is distributed in the hope that it will be useful,
							 | 
						|
								#    but WITHOUT ANY WARRANTY; without even the implied warranty of
							 | 
						|
								#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
							 | 
						|
								#    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
							 | 
						|
								#
							 | 
						|
								#    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
							 | 
						|
								#    (LGPL v3) along with this program.
							 | 
						|
								#    If not, see <http://www.gnu.org/licenses/>.
							 | 
						|
								#
							 | 
						|
								#############################################################################
							 | 
						|
								import json
							 | 
						|
								import werkzeug.urls
							 | 
						|
								import werkzeug.utils
							 | 
						|
								from odoo.http import request
							 | 
						|
								from odoo.addons.auth_signup.controllers.main import AuthSignupHome as Home
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								class OAuthLogin(Home):
							 | 
						|
								    """This class is used for oauth login"""
							 | 
						|
								
							 | 
						|
								    def list_providers(self):
							 | 
						|
								        """Which provides the oauth provider to login to the odoo"""
							 | 
						|
								        super().list_providers()
							 | 
						|
								        try:
							 | 
						|
								            auth_providers = request.env[
							 | 
						|
								                'auth.oauth.provider'].sudo().search_read(
							 | 
						|
								                [('enabled', '=', True)])
							 | 
						|
								        except Exception:
							 | 
						|
								            auth_providers = []
							 | 
						|
								        for rec in auth_providers:
							 | 
						|
								            return_url = request.httprequest.url_root + 'auth_oauth/signin'
							 | 
						|
								            state = self.get_state(rec)
							 | 
						|
								            params = dict(
							 | 
						|
								                response_type=rec['response_type'],
							 | 
						|
								                client_id=rec['client_id'],
							 | 
						|
								                redirect_uri=return_url,
							 | 
						|
								                scope=rec['scope'],
							 | 
						|
								                state=json.dumps(state),
							 | 
						|
								            )
							 | 
						|
								            rec['auth_link'] = "%s?%s" % (
							 | 
						|
								                rec['auth_endpoint'], werkzeug.urls.url_encode(params))
							 | 
						|
								        return auth_providers
							 | 
						|
								
							 |