@@ -11,7 +11,8 @@ use serde::{Deserialize, Serialize};
1111use std:: collections:: HashMap ;
1212use std:: fmt;
1313use super :: error:: OauthError ;
14- use super :: tools;
14+
15+ use actix_web:: http:: uri:: Scheme ;
1516
1617#[ derive( Clone , Debug ) ]
1718pub struct OauthInfo {
@@ -71,11 +72,11 @@ impl Provider {
7172 }
7273 }
7374
74- fn get_login_url_params ( & self , host : String , state : String ) -> Vec < ( & str , String ) > {
75+ fn get_login_url_params ( & self , scheme : Scheme , host : String , state : String ) -> Vec < ( & str , String ) > {
7576 let mut params = vec ! [
7677 ( "client_id" , self . get_oauth_info( ) . client_id) ,
7778 ( "state" , state) ,
78- ( "redirect_uri" , format!( "{}://{}/login/{}/callback" , tools :: scheme( ) , host, self . name( ) ) ) ,
79+ ( "redirect_uri" , format!( "{}://{}/login/{}/callback" , scheme, host, self . name( ) ) ) ,
7980 ] ;
8081
8182 #[ cfg( feature = "github-login" ) ]
@@ -103,9 +104,9 @@ impl Provider {
103104 params
104105 }
105106
106- pub fn get_login_url ( & self , host : String , state : String ) -> String {
107+ pub fn get_login_url ( & self , scheme : Scheme , host : String , state : String ) -> String {
107108
108- let params = self . get_login_url_params ( host, state) ;
109+ let params = self . get_login_url_params ( scheme , host, state) ;
109110
110111 let oauth_url = match self {
111112 #[ cfg( feature = "github-login" ) ]
@@ -122,16 +123,16 @@ impl Provider {
122123 }
123124
124125 #[ allow( unused_variables) ]
125- pub async fn get_user_info ( & self , host : String , token : String ) -> Result < ThirdPartyUserInfo , OauthError > {
126+ pub async fn get_user_info ( & self , scheme : Scheme , host : String , token : String ) -> Result < ThirdPartyUserInfo , OauthError > {
126127 let user_info: OauthUserInfo = match self {
127128 #[ cfg( feature = "github-login" ) ]
128129 Self :: Github ( oauth) => github:: user_info ( oauth, host) . await ?. into ( ) ,
129130 #[ cfg( feature = "gitlab-login" ) ]
130- Self :: Gitlab ( oauth) => gitlab:: user_info ( oauth, host, token) . await ?. into ( ) ,
131+ Self :: Gitlab ( oauth) => gitlab:: user_info ( scheme , oauth, host, token) . await ?. into ( ) ,
131132 #[ cfg( feature = "google-login" ) ]
132- Self :: Google ( oauth) => google:: user_info ( oauth, host, token) . await ?,
133+ Self :: Google ( oauth) => google:: user_info ( scheme , oauth, host, token) . await ?,
133134 #[ cfg( feature = "microsoft-login" ) ]
134- Self :: Microsoft ( oauth) => microsoft:: user_info ( oauth, host, token) . await ?. into ( ) ,
135+ Self :: Microsoft ( oauth) => microsoft:: user_info ( scheme , oauth, host, token) . await ?. into ( ) ,
135136 } ;
136137
137138 Ok ( ThirdPartyUserInfo {
0 commit comments