package auth
import "net/http"
// == define error HTML here ==
const oauthNotConfigured = `
Your Netmaker server does not have OAuth configured.
Please visit the docs here to learn how to.
`
const userNotAllowed = `
Only administrators can access the Dashboard. Please contact your administrator to elevate your account.
Non-Admins can access the netmaker networks using RemoteAccessClient.
`
const userFirstTimeSignUp = `
Thank you for signing up. Please contact your administrator for access.
`
const userSignUpApprovalPending = `
Your account is yet to be approved. Please contact your administrator for access.
`
const userNotFound = `
User Not Found.
`
const somethingwentwrong = `
Something went wrong. Contact Admin.
`
const notallowedtosignup = `
Your email is not allowed. Please contact your administrator.
`
func handleOauthUserNotFound(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusNotFound)
response.Write([]byte(userNotFound))
}
func handleOauthUserNotAllowed(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusForbidden)
response.Write([]byte(userNotAllowed))
}
func handleFirstTimeOauthUserSignUp(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusForbidden)
response.Write([]byte(userFirstTimeSignUp))
}
func handleOauthUserSignUpApprovalPending(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusForbidden)
response.Write([]byte(userSignUpApprovalPending))
}
func handleOauthUserNotAllowedToSignUp(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusForbidden)
response.Write([]byte(notallowedtosignup))
}
// handleOauthNotConfigured - returns an appropriate html page when oauth is not configured on netmaker server but an oauth login was attempted
func handleOauthNotConfigured(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusInternalServerError)
response.Write([]byte(oauthNotConfigured))
}
func handleSomethingWentWrong(response http.ResponseWriter) {
response.Header().Set("Content-Type", "text/html; charset=utf-8")
response.WriteHeader(http.StatusInternalServerError)
response.Write([]byte(somethingwentwrong))
}