mirror of
				https://github.com/steveiliop56/tinyauth.git
				synced 2025-10-31 14:15:50 +00:00 
			
		
		
		
	feat: add option to disable continue screen
This commit is contained in:
		| @@ -92,6 +92,7 @@ var rootCmd = &cobra.Command{ | |||||||
| 			Secret:          config.Secret, | 			Secret:          config.Secret, | ||||||
| 			AppURL:          config.AppURL, | 			AppURL:          config.AppURL, | ||||||
| 			CookieSecure:    config.CookieSecure, | 			CookieSecure:    config.CookieSecure, | ||||||
|  | 			DisableContinue: config.DisableContinue, | ||||||
| 		}, hooks, auth, providers) | 		}, hooks, auth, providers) | ||||||
|  |  | ||||||
| 		// Setup routes | 		// Setup routes | ||||||
| @@ -138,6 +139,7 @@ func init() { | |||||||
| 	rootCmd.Flags().String("generic-auth-url", "", "Generic OAuth auth URL.") | 	rootCmd.Flags().String("generic-auth-url", "", "Generic OAuth auth URL.") | ||||||
| 	rootCmd.Flags().String("generic-token-url", "", "Generic OAuth token URL.") | 	rootCmd.Flags().String("generic-token-url", "", "Generic OAuth token URL.") | ||||||
| 	rootCmd.Flags().String("generic-user-info-url", "", "Generic OAuth user info URL.") | 	rootCmd.Flags().String("generic-user-info-url", "", "Generic OAuth user info URL.") | ||||||
|  | 	rootCmd.Flags().Bool("disable-continue", false, "Disable continue screen and redirect to app directly.") | ||||||
| 	viper.BindEnv("port", "PORT") | 	viper.BindEnv("port", "PORT") | ||||||
| 	viper.BindEnv("address", "ADDRESS") | 	viper.BindEnv("address", "ADDRESS") | ||||||
| 	viper.BindEnv("secret", "SECRET") | 	viper.BindEnv("secret", "SECRET") | ||||||
| @@ -155,5 +157,6 @@ func init() { | |||||||
| 	viper.BindEnv("generic-auth-url", "GENERIC_AUTH_URL") | 	viper.BindEnv("generic-auth-url", "GENERIC_AUTH_URL") | ||||||
| 	viper.BindEnv("generic-token-url", "GENERIC_TOKEN_URL") | 	viper.BindEnv("generic-token-url", "GENERIC_TOKEN_URL") | ||||||
| 	viper.BindEnv("generic-user-info-url", "GENERIC_USER_INFO_URL") | 	viper.BindEnv("generic-user-info-url", "GENERIC_USER_INFO_URL") | ||||||
|  | 	viper.BindEnv("disable-continue", "DISABLE_CONTINUE") | ||||||
| 	viper.BindPFlags(rootCmd.Flags()) | 	viper.BindPFlags(rootCmd.Flags()) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -208,6 +208,7 @@ func (api *API) SetupRoutes() { | |||||||
| 				"oauth":               false, | 				"oauth":               false, | ||||||
| 				"provider":            "", | 				"provider":            "", | ||||||
| 				"configuredProviders": api.Providers.GetConfiguredProviders(), | 				"configuredProviders": api.Providers.GetConfiguredProviders(), | ||||||
|  | 				"disableContinue":     api.Config.DisableContinue, | ||||||
| 			}) | 			}) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| @@ -220,6 +221,7 @@ func (api *API) SetupRoutes() { | |||||||
| 			"oauth":               userContext.OAuth, | 			"oauth":               userContext.OAuth, | ||||||
| 			"provider":            userContext.Provider, | 			"provider":            userContext.Provider, | ||||||
| 			"configuredProviders": api.Providers.GetConfiguredProviders(), | 			"configuredProviders": api.Providers.GetConfiguredProviders(), | ||||||
|  | 			"disableContinue":     api.Config.DisableContinue, | ||||||
| 		}) | 		}) | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -36,6 +36,7 @@ type Config struct { | |||||||
| 	GenericAuthURL      string `mapstructure:"generic-auth-url"` | 	GenericAuthURL      string `mapstructure:"generic-auth-url"` | ||||||
| 	GenericTokenURL     string `mapstructure:"generic-token-url"` | 	GenericTokenURL     string `mapstructure:"generic-token-url"` | ||||||
| 	GenericUserInfoURL  string `mapstructure:"generic-user-info-url"` | 	GenericUserInfoURL  string `mapstructure:"generic-user-info-url"` | ||||||
|  | 	DisableContinue     bool   `mapstructure:"disable-continue"` | ||||||
| } | } | ||||||
|  |  | ||||||
| type UserContext struct { | type UserContext struct { | ||||||
| @@ -51,6 +52,7 @@ type APIConfig struct { | |||||||
| 	Secret          string | 	Secret          string | ||||||
| 	AppURL          string | 	AppURL          string | ||||||
| 	CookieSecure    bool | 	CookieSecure    bool | ||||||
|  | 	DisableContinue bool | ||||||
| } | } | ||||||
|  |  | ||||||
| type OAuthConfig struct { | type OAuthConfig struct { | ||||||
|   | |||||||
| @@ -9,12 +9,16 @@ export const ContinuePage = () => { | |||||||
|   const params = new URLSearchParams(queryString); |   const params = new URLSearchParams(queryString); | ||||||
|   const redirectUri = params.get("redirect_uri"); |   const redirectUri = params.get("redirect_uri"); | ||||||
|  |  | ||||||
|   const { isLoggedIn } = useUserContext(); |   const { isLoggedIn, disableContinue } = useUserContext(); | ||||||
|  |  | ||||||
|   if (!isLoggedIn) { |   if (!isLoggedIn) { | ||||||
|     return <Navigate to="/login" />; |     return <Navigate to="/login" />; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   if (disableContinue && redirectUri !== "null") { | ||||||
|  |     window.location.replace(redirectUri!); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   const redirect = () => { |   const redirect = () => { | ||||||
|     notifications.show({ |     notifications.show({ | ||||||
|       title: "Redirecting", |       title: "Redirecting", | ||||||
|   | |||||||
| @@ -96,6 +96,13 @@ export const LoginPage = () => { | |||||||
|     <Layout> |     <Layout> | ||||||
|       <Title ta="center">Tinyauth</Title> |       <Title ta="center">Tinyauth</Title> | ||||||
|       <Paper shadow="md" p="xl" mt={30} radius="md" withBorder> |       <Paper shadow="md" p="xl" mt={30} radius="md" withBorder> | ||||||
|  |         {configuredProviders.length === 0 && ( | ||||||
|  |           <Text size="lg" mb="md" fw={500} ta="center"> | ||||||
|  |             Welcome back, please login | ||||||
|  |           </Text> | ||||||
|  |         )} | ||||||
|  |         {configuredProviders.length > 0 && ( | ||||||
|  |           <> | ||||||
|             <Text size="lg" fw={500} ta="center"> |             <Text size="lg" fw={500} ta="center"> | ||||||
|               Welcome back, login with |               Welcome back, login with | ||||||
|             </Text> |             </Text> | ||||||
| @@ -104,7 +111,9 @@ export const LoginPage = () => { | |||||||
|                 <Grid.Col span="content"> |                 <Grid.Col span="content"> | ||||||
|                   <Button |                   <Button | ||||||
|                     radius="xl" |                     radius="xl" | ||||||
|                 leftSection={<GoogleIcon style={{ width: 14, height: 14 }} />} |                     leftSection={ | ||||||
|  |                       <GoogleIcon style={{ width: 14, height: 14 }} /> | ||||||
|  |                     } | ||||||
|                     variant="default" |                     variant="default" | ||||||
|                     onClick={() => loginOAuthMutation.mutate("google")} |                     onClick={() => loginOAuthMutation.mutate("google")} | ||||||
|                     loading={loginOAuthMutation.isLoading} |                     loading={loginOAuthMutation.isLoading} | ||||||
| @@ -117,7 +126,9 @@ export const LoginPage = () => { | |||||||
|                 <Grid.Col span="content"> |                 <Grid.Col span="content"> | ||||||
|                   <Button |                   <Button | ||||||
|                     radius="xl" |                     radius="xl" | ||||||
|                 leftSection={<GithubIcon style={{ width: 14, height: 14 }} />} |                     leftSection={ | ||||||
|  |                       <GithubIcon style={{ width: 14, height: 14 }} /> | ||||||
|  |                     } | ||||||
|                     variant="default" |                     variant="default" | ||||||
|                     onClick={() => loginOAuthMutation.mutate("github")} |                     onClick={() => loginOAuthMutation.mutate("github")} | ||||||
|                     loading={loginOAuthMutation.isLoading} |                     loading={loginOAuthMutation.isLoading} | ||||||
| @@ -130,7 +141,9 @@ export const LoginPage = () => { | |||||||
|                 <Grid.Col span="content"> |                 <Grid.Col span="content"> | ||||||
|                   <Button |                   <Button | ||||||
|                     radius="xl" |                     radius="xl" | ||||||
|                 leftSection={<OAuthIcon style={{ width: 14, height: 14 }} />} |                     leftSection={ | ||||||
|  |                       <OAuthIcon style={{ width: 14, height: 14 }} /> | ||||||
|  |                     } | ||||||
|                     variant="default" |                     variant="default" | ||||||
|                     onClick={() => loginOAuthMutation.mutate("generic")} |                     onClick={() => loginOAuthMutation.mutate("generic")} | ||||||
|                     loading={loginOAuthMutation.isLoading} |                     loading={loginOAuthMutation.isLoading} | ||||||
| @@ -145,6 +158,8 @@ export const LoginPage = () => { | |||||||
|               labelPosition="center" |               labelPosition="center" | ||||||
|               my="lg" |               my="lg" | ||||||
|             /> |             /> | ||||||
|  |           </> | ||||||
|  |         )} | ||||||
|         <form onSubmit={form.onSubmit(handleSubmit)}> |         <form onSubmit={form.onSubmit(handleSubmit)}> | ||||||
|           <TextInput |           <TextInput | ||||||
|             label="Email" |             label="Email" | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ export const userContextSchema = z.object({ | |||||||
|   oauth: z.boolean(), |   oauth: z.boolean(), | ||||||
|   provider: z.string(), |   provider: z.string(), | ||||||
|   configuredProviders: z.array(z.string()), |   configuredProviders: z.array(z.string()), | ||||||
|  |   disableContinue: z.boolean(), | ||||||
| }); | }); | ||||||
|  |  | ||||||
| export type UserContextSchemaType = z.infer<typeof userContextSchema>; | export type UserContextSchemaType = z.infer<typeof userContextSchema>; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stavros
					Stavros