How to use NoValidate method of html Package

Best K6 code snippet using html.NoValidate

template.go

Source:template.go Github

copy

Full Screen

1package webapp2import (3 "github.com/skygeario/skygear-server/pkg/core/config"4 "github.com/skygeario/skygear-server/pkg/core/template"5)6const (7 // Components8 TemplateItemTypeAuthUIHTMLHeadHTML config.TemplateItemType = "auth_ui_html_head.html"9 TemplateItemTypeAuthUIHeaderHTML config.TemplateItemType = "auth_ui_header.html"10 TemplateItemTypeAuthUIFooterHTML config.TemplateItemType = "auth_ui_footer.html"11 // Interaction entrypoints12 TemplateItemTypeAuthUILoginHTML config.TemplateItemType = "auth_ui_login.html"13 TemplateItemTypeAuthUISignupHTML config.TemplateItemType = "auth_ui_signup.html"14 TemplateItemTypeAuthUIPromoteHTML config.TemplateItemType = "auth_ui_promote.html"15 // Interaction steps16 // nolint: gosec17 TemplateItemTypeAuthUIEnterPasswordHTML config.TemplateItemType = "auth_ui_enter_password.html"18 // nolint: gosec19 TemplateItemTypeAuthUICreatePasswordHTML config.TemplateItemType = "auth_ui_create_password.html"20 TemplateItemTypeAuthUIOOBOTPHTML config.TemplateItemType = "auth_ui_oob_otp_html"21 TemplateItemTypeAuthUIEnterLoginIDHTML config.TemplateItemType = "auth_ui_enter_login_id.html"22 // Forgot Password23 // nolint: gosec24 TemplateItemTypeAuthUIForgotPasswordHTML config.TemplateItemType = "auth_ui_forgot_password.html"25 // nolint: gosec26 TemplateItemTypeAuthUIForgotPasswordSuccessHTML config.TemplateItemType = "auth_ui_forgot_password_success.html"27 // nolint: gosec28 TemplateItemTypeAuthUIResetPasswordHTML config.TemplateItemType = "auth_ui_reset_password.html"29 // nolint: gosec30 TemplateItemTypeAuthUIResetPasswordSuccessHTML config.TemplateItemType = "auth_ui_reset_password_success.html"31 // Logout32 TemplateItemTypeAuthUILogoutHTML config.TemplateItemType = "auth_ui_logout.html"33 // Settings34 TemplateItemTypeAuthUISettingsHTML config.TemplateItemType = "auth_ui_settings.html"35 TemplateItemTypeAuthUISettingsIdentityHTML config.TemplateItemType = "auth_ui_settings_identity.html"36)37var TemplateAuthUIHTMLHeadHTML = template.Spec{38 Type: TemplateItemTypeAuthUIHTMLHeadHTML,39 IsHTML: true,40 Default: `41{{ define "auth_ui_html_head.html" }}42<head>43<title>{{ .app_name }}</title>44<meta name="viewport" content="width=device-width, initial-scale=1">45<link rel="stylesheet" href="{{ .x_static_asset_url_prefix }}/css/main.css">46<script src="{{ .x_static_asset_url_prefix}}/js/main.js"></script>47{{ if .x_css }}48<style>49{{ .x_css }}50</style>51{{ end }}52</head>53{{ end }}54`,55}56var TemplateAuthUIHeaderHTML = template.Spec{57 Type: TemplateItemTypeAuthUIHeaderHTML,58 IsHTML: true,59 Default: `60{{ define "auth_ui_header.html" }}61{{ if .logo_uri }}62<div class="logo" style="background-image: url('{{ .logo_uri }}'); background-position: center; background-size: contain; background-repeat: no-repeat"></div>63{{ else }}64<div class="logo"></div>65{{ end }}66{{ end }}67`,68}69var TemplateAuthUIFooterHTML = template.Spec{70 Type: TemplateItemTypeAuthUIFooterHTML,71 IsHTML: true,72 Default: `73{{ define "auth_ui_footer.html" }}74<div class="skygear-logo"></div>75{{ end }}76`,77}78const defineError = `79{{ define "ERROR" }}80{{ if .x_error }}81<ul class="errors">82 {{ if eq .x_error.reason "ValidationFailed" }}83 {{ range .x_error.info.causes }}84 {{ if and (eq .kind "Required") (eq .pointer "/x_login_id" ) }}85 <li class="error-txt">{{ localize "error-login-id-required" $.x_login_page_text_login_id_variant }}</li>86 {{ else if and (eq .kind "Required") (eq .pointer "/x_password" ) }}87 <li class="error-txt">{{ localize "error-password-or-code-required" }}</li>88 {{ else if and (eq .kind "Required") (eq .pointer "/x_calling_code" ) }}89 <li class="error-txt">{{ localize "error-calling-code-required" }}</li>90 {{ else if and (eq .kind "Required") (eq .pointer "/x_national_number" ) }}91 <li class="error-txt">{{ localize "error-phone-number-required" }}</li>92 {{ else if and (eq .kind "StringFormat") (eq .details.format "phone" ) }}93 <li class="error-txt">{{ localize "error-phone-number-format" }}</li>94 {{ else if and (eq .kind "StringFormat") (eq .details.format "email") }}95 <li class="error-txt">{{ localize "error-invalid-email" }}</li>96 {{ else if and (eq .kind "StringFormat") (eq .details.format "username") }}97 <li class="error-txt">{{ localize "error-invalid-username" }}</li>98 {{ else }}99 <li class="error-txt">{{ .message }}</li>100 {{ end }}101 {{ end }}102 {{ else if eq .x_error.reason "InvalidCredentials" }}103 <li class="error-txt">{{ localize "error-invalid-credentials" }}</li>104 {{ else if eq .x_error.reason "PasswordPolicyViolated" }}105 <!-- This error is handled differently -->106 {{ else if eq .x_error.reason "PasswordResetFailed" }}107 <li class="error-txt">{{ localize "error-password-reset-failed" }}</li>108 {{ else if eq .x_error.reason "DuplicatedIdentity" }}109 <li class="error-txt">{{ localize "error-duplicated-identity" }}</li>110 {{ else if eq .x_error.reason "InvalidIdentityRequest" }}111 <li class="error-txt">{{ localize "error-remove-last-identity" }}</li>112 {{ else }}113 <li class="error-txt">{{ .x_error.message }}</li>114 {{ end }}115</ul>116{{ end }}117{{ end }}118`119// nolint: gosec120const definePasswordPolicy = `121{{ define "PASSWORD_POLICY" }}122{{ if .x_password_policies }}123<ul>124{{ range .x_password_policies }}125 {{ if eq .kind "PasswordTooShort" }}126 <li class="primary-txt password-policy length {{ template "PASSWORD_POLICY_CLASS" . }}" data-min-length="{{ .min_length}}">127 {{ localize "password-policy-minimum-length" .min_length }}128 </li>129 {{ end }}130 {{ if eq .kind "PasswordUppercaseRequired" }}131 <li class="primary-txt password-policy uppercase {{ template "PASSWORD_POLICY_CLASS" . }}">132 {{ localize "password-policy-uppercase" }}133 </li>134 {{ end }}135 {{ if eq .kind "PasswordLowercaseRequired" }}136 <li class="primary-txt password-policy lowercase {{ template "PASSWORD_POLICY_CLASS" . }}">137 {{ localize "password-policy-lowercase" }}138 </li>139 {{ end }}140 {{ if eq .kind "PasswordDigitRequired" }}141 <li class="primary-txt password-policy digit {{ template "PASSWORD_POLICY_CLASS" . }}">142 {{ localize "password-policy-digit" }}143 </li>144 {{ end }}145 {{ if eq .kind "PasswordSymbolRequired" }}146 <li class="primary-txt password-policy symbol {{ template "PASSWORD_POLICY_CLASS" . }}">147 {{ localize "password-policy-symbol" }}148 </li>149 {{ end }}150 {{ if eq .kind "PasswordContainingExcludedKeywords" }}151 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">152 {{ localize "password-policy-banned-words" }}153 </li>154 {{ end }}155 {{ if eq .kind "PasswordBelowGuessableLevel" }}156 {{ if eq .min_level 1.0 }}157 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">158 {{ localize "password-policy-guessable-level-1" }}159 </li>160 {{ end }}161 {{ if eq .min_level 2.0 }}162 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">163 {{ localize "password-policy-guessable-level-2" }}164 </li>165 {{ end }}166 {{ if eq .min_level 3.0 }}167 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">168 {{ localize "password-policy-guessable-level-3" }}169 </li>170 {{ end }}171 {{ if eq .min_level 4.0 }}172 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">173 {{ localize "password-policy-guessable-level-4" }}174 </li>175 {{ end }}176 {{ if eq .min_level 5.0 }}177 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">178 {{ localize "password-policy-guessable-level-5" }}179 </li>180 {{ end }}181 {{ end }}182{{ end }}183</ul>184{{ end }}185{{ end }}186`187// nolint: gosec188const definePasswordPolicyClass = `189{{- define "PASSWORD_POLICY_CLASS" -}}190{{- if .x_error_is_password_policy_violated -}}191{{- if .x_is_violated -}}192violated193{{- else -}}194passed195{{- end -}}196{{- end -}}197{{- end -}}198`199var defines = []string{200 defineError,201 definePasswordPolicy,202 definePasswordPolicyClass,203}204var components = []config.TemplateItemType{205 TemplateItemTypeAuthUIHTMLHeadHTML,206 TemplateItemTypeAuthUIHeaderHTML,207 TemplateItemTypeAuthUIFooterHTML,208}209var TemplateAuthUILoginHTML = template.Spec{210 Type: TemplateItemTypeAuthUILoginHTML,211 IsHTML: true,212 Translation: TemplateItemTypeAuthUITranslationJSON,213 Defines: defines,214 Components: components,215 Default: `<!DOCTYPE html>216<html>217{{ template "auth_ui_html_head.html" . }}218<body class="page">219 <div class="content">220 {{ template "auth_ui_header.html" . }}221 <div class="authorize-form">222 <div class="authorize-idp-section">223 {{ range .x_identity_candidates }}224 {{ if eq .type "oauth" }}225 <form class="authorize-idp-form" method="post" novalidate>226 {{ $.csrfField }}227 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">228 {{- if eq .provider_type "apple" -}}229 {{ localize "sign-in-apple" }}230 {{- end -}}231 {{- if eq .provider_type "google" -}}232 {{ localize "sign-in-google" }}233 {{- end -}}234 {{- if eq .provider_type "facebook" -}}235 {{ localize "sign-in-facebook" }}236 {{- end -}}237 {{- if eq .provider_type "linkedin" -}}238 {{ localize "sign-in-linkedin" }}239 {{- end -}}240 {{- if eq .provider_type "azureadv2" -}}241 {{ localize "sign-in-azureadv2" }}242 {{- end -}}243 </button>244 </form>245 {{ end }}246 {{ end }}247 </div>248 {{ $has_oauth := false }}249 {{ $has_login_id := false }}250 {{ range .x_identity_candidates }}251 {{ if eq .type "oauth" }}252 {{ $has_oauth = true }}253 {{ end }}254 {{ if eq .type "login_id" }}255 {{ $has_login_id = true }}256 {{ end }}257 {{ end }}258 {{ if $has_oauth }}{{ if $has_login_id }}259 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>260 {{ end }}{{ end }}261 {{ template "ERROR" . }}262 <form class="authorize-loginid-form" method="post" novalidate>263 {{ $.csrfField }}264 {{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if .x_login_page_login_id_has_phone }}265 <div class="phone-input">266 <select class="input select primary-txt" name="x_calling_code">267 {{ range .x_calling_codes }}268 <option269 value="{{ . }}"270 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}271 selected272 {{ end }}{{ end }}273 >274 +{{ . }}275 </option>276 {{ end }}277 </select>278 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">279 </div>280 {{ end }}{{ end }}{{ end }}281 {{ if .x_login_id_input_type }}{{ if not (eq .x_login_id_input_type "phone") }}{{ if (not (eq .x_login_page_text_login_id_variant "none")) }}282 <input class="input text-input primary-txt" type="{{ .x_login_page_text_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "login-id-placeholder" .x_login_page_text_login_id_variant }}">283 {{ end }}{{ end }}{{ end }}284 {{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if (not (eq .x_login_page_text_login_id_variant "none")) }}285 <a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" .x_login_page_text_login_id_input_type }}">{{ localize "use-text-login-id-description" .x_login_page_text_login_id_variant }}</a>286 {{ end }}{{ end }}{{ end }}287 {{ if .x_login_id_input_type }}{{ if not (eq .x_login_id_input_type "phone") }}{{ if .x_login_page_login_id_has_phone }}288 <a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "phone" }}">{{ localize "use-phone-login-id-description" }}</a>289 {{ end }}{{ end }}{{ end }}290 <div class="link">291 <span class="primary-text">{{ localize "signup-button-hint" }}</span>292 <a href="{{ call .MakeURLWithPathWithoutX "/signup" }}">{{ localize "signup-button-label" }}</a>293 </div>294 {{ if .x_password_authenticator_enabled }}295 <a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label" }}</a>296 {{ end }}297 {{ if or .x_login_page_login_id_has_phone (not (eq .x_login_page_text_login_id_variant "none")) }}298 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>299 {{ end }}300 </form>301 </div>302 {{ template "auth_ui_footer.html" . }}303 </div>304</body>305</html>306`,307}308var TemplateAuthUIEnterPasswordHTML = template.Spec{309 Type: TemplateItemTypeAuthUIEnterPasswordHTML,310 IsHTML: true,311 Translation: TemplateItemTypeAuthUITranslationJSON,312 Defines: defines,313 Components: components,314 Default: `<!DOCTYPE html>315<html>316{{ template "auth_ui_html_head.html" . }}317<body class="page">318<div class="content">319{{ template "auth_ui_header.html" . }}320<form class="simple-form vertical-form form-fields-container" method="post" novalidate>321{{ $.csrfField }}322<div class="nav-bar">323 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>324 <div class="login-id primary-txt">325 {{ if .x_national_number }}326 +{{ .x_calling_code}} {{ .x_national_number }}327 {{ else }}328 {{ .x_login_id }}329 {{ end }}330 </div>331</div>332<div class="title primary-txt">{{ localize "enter-password-page-title" }}</div>333{{ template "ERROR" . }}334<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">335<input id="password" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">336<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>337<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>338{{ if .x_password_authenticator_enabled }}339<a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label--enter-password-page" }}</a>340{{ end }}341<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>342</form>343{{ template "auth_ui_footer.html" . }}344</div>345</body>346</html>347`,348}349var TemplateAuthUIOOBOTPHTML = template.Spec{350 Type: TemplateItemTypeAuthUIOOBOTPHTML,351 IsHTML: true,352 Translation: TemplateItemTypeAuthUITranslationJSON,353 Defines: defines,354 Components: components,355 Default: `<!DOCTYPE html>356<html>357{{ template "auth_ui_html_head.html" . }}358<body class="page">359<div class="content">360{{ template "auth_ui_header.html" . }}361<div class="simple-form vertical-form form-fields-container">362<div class="nav-bar">363 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>364</div>365{{ if eq .x_login_id_input_type "phone" }}366<div class="title primary-txt">{{ localize "oob-otp-page-title--sms" }}</div>367{{ end }}368{{ if not (eq .x_login_id_input_type "phone") }}369<div class="title primary-txt">{{ localize "oob-otp-page-title--email" }}</div>370{{ end }}371{{ template "ERROR" . }}372{{ if eq .x_login_id_input_type "phone" }}373<div class="description primary-txt">{{ localize "oob-otp-description--sms" .x_oob_otp_code_length .x_calling_code .x_national_number }}</div>374{{ end }}375{{ if not (eq .x_login_id_input_type "phone") }}376<div class="description primary-txt">{{ localize "oob-otp-description--email" .x_oob_otp_code_length .x_login_id }}</div>377{{ end }}378<form class="vertical-form form-fields-container" method="post" novalidate>379{{ $.csrfField }}380<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">381<input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_password" placeholder="{{ localize "oob-otp-placeholder" }}">382<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>383</form>384<form class="link oob-otp-trigger-form" method="post" novalidate>385{{ $.csrfField }}386<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">387<span class="primary-txt">{{ localize "oob-otp-resend-button-hint" }}</span>388<button id="resend-button" class="anchor" type="submit" name="trigger" value="true"389 data-cooldown="{{ .x_oob_otp_code_send_cooldown }}"390 data-label="{{ localize "oob-otp-resend-button-label" }}"391 data-label-unit="{{ localize "oob-otp-resend-button-label--unit" }}">{{ localize "oob-otp-resend-button-label" }}</button>392</form>393</div>394{{ template "auth_ui_footer.html" . }}395</div>396</body>397</html>398`,399}400var TemplateAuthUIEnterLoginIDHTML = template.Spec{401 Type: TemplateItemTypeAuthUIEnterLoginIDHTML,402 IsHTML: true,403 Translation: TemplateItemTypeAuthUITranslationJSON,404 Defines: defines,405 Components: components,406 Default: `<!DOCTYPE html>407<html>408{{ template "auth_ui_html_head.html" . }}409<body class="page">410<div class="content">411{{ template "auth_ui_header.html" . }}412<div class="simple-form vertical-form form-fields-container">413<div class="nav-bar">414 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>415</div>416<div class="title primary-txt">417 {{ if .x_old_login_id_value }}418 {{ localize "enter-login-id-page-title--change" .x_login_id_key }}419 {{ else }}420 {{ localize "enter-login-id-page-title--add" .x_login_id_key }}421 {{ end }}422</div>423{{ template "ERROR" . }}424<form class="vertical-form form-fields-container" method="post" novalidate>425{{ $.csrfField }}426<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">427<input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">428<input type="hidden" name="x_login_id_type" value="{{ .x_login_id_type }}">429<input type="hidden" name="x_login_id_input_type" value="{{ .x_login_id_input_type }}">430<input type="hidden" name="x_old_login_id_value" value="{{ .x_old_login_id_value }}">431{{ if eq .x_login_id_input_type "phone" }}432<div class="phone-input">433 <select class="input select primary-txt" name="x_calling_code">434 {{ range .x_calling_codes }}435 <option436 value="{{ . }}"437 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}438 selected439 {{ end }}{{ end }}440 >441 +{{ . }}442 </option>443 {{ end }}444 </select>445 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">446</div>447{{ else }}448<input class="input text-input primary-txt" type="{{ .x_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "login-id-placeholder" .x_login_id_type }}">449{{ end }}450<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>451</form>452{{ if .x_old_login_id_value }}453<form class="enter-login-id-remove-form" method="post" novalidate>454{{ $.csrfField }}455<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">456<input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">457<input type="hidden" name="x_login_id_type" value="{{ .x_login_id_type }}">458<input type="hidden" name="x_login_id_input_type" value="{{ .x_login_id_input_type }}">459<input type="hidden" name="x_old_login_id_value" value="{{ .x_old_login_id_value }}">460<button class="anchor" type="submit" name="x_action" value="remove">{{ localize "disconnect-button-label" }}</button>461{{ end }}462</form>463</div>464{{ template "auth_ui_footer.html" . }}465</div>466</body>467</html>468`,469}470var TemplateAuthUIForgotPasswordHTML = template.Spec{471 Type: TemplateItemTypeAuthUIForgotPasswordHTML,472 IsHTML: true,473 Translation: TemplateItemTypeAuthUITranslationJSON,474 Defines: defines,475 Components: components,476 Default: `<!DOCTYPE html>477<html>478{{ template "auth_ui_html_head.html" . }}479<body class="page">480<div class="content">481{{ template "auth_ui_header.html" . }}482<form class="simple-form vertical-form form-fields-container" method="post" novalidate>483{{ $.csrfField }}484<div class="nav-bar">485 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>486</div>487<div class="title primary-txt">{{ localize "forgot-password-page-title" }}</div>488{{ template "ERROR" . }}489{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if .x_login_page_login_id_has_phone }}490<div class="description primary-txt">{{ localize "forgot-password-phone-description" }}</div>491<div class="phone-input">492 <select class="input select primary-txt" name="x_calling_code">493 {{ range .x_calling_codes }}494 <option495 value="{{ . }}"496 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}497 selected498 {{ end }}{{ end }}499 >500 +{{ . }}501 </option>502 {{ end }}503 </select>504 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">505</div>506{{ end }}{{ end }}{{ end }}507{{ if .x_login_id_input_type }}{{ if (not (eq .x_login_id_input_type "phone")) }}{{ if or (eq .x_login_page_text_login_id_variant "email") (eq .x_login_page_text_login_id_variant "email_or_username") }}508<div class="description primary-txt">{{ localize "forgot-password-email-description" }}</div>509<input class="input text-input primary-txt" type="{{ .x_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "email-placeholder" }}">510{{ end }}{{ end }}{{ end }}511{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if or (eq .x_login_page_text_login_id_variant "email") (eq .x_login_page_text_login_id_variant "email_or_username") }}512<a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "email" }}">{{ localize "use-email-login-id-description" }}</a>513{{ end }}{{ end }}{{ end }}514{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "email" }}{{ if .x_login_page_login_id_has_phone }}515<a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "phone" }}">{{ localize "use-phone-login-id-description" }}</a>516{{ end }}{{ end }}{{ end }}517{{ if or .x_login_page_login_id_has_phone (not (eq .x_login_page_text_login_id_variant "none")) }}518<button class="btn primary-btn submit-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>519{{ end }}520</form>521{{ template "auth_ui_footer.html" . }}522</div>523</body>524</html>525`,526}527var TemplateAuthUIForgotPasswordSuccessHTML = template.Spec{528 Type: TemplateItemTypeAuthUIForgotPasswordSuccessHTML,529 IsHTML: true,530 Translation: TemplateItemTypeAuthUITranslationJSON,531 Defines: defines,532 Components: components,533 Default: `<!DOCTYPE html>534<html>535{{ template "auth_ui_html_head.html" . }}536<body class="page">537<div class="content">538{{ template "auth_ui_header.html" . }}539<div class="simple-form vertical-form form-fields-container">540<div class="title primary-txt">{{ localize "forgot-password-success-page-title" }}</div>541{{ template "ERROR" . }}542<div class="description primary-txt">{{ localize "forgot-password-success-description" .x_login_id }}</div>543<a class="btn primary-btn align-self-flex-end" href="{{ call .MakeURLWithPathWithoutX "/login" }}">{{ localize "login-button-label--forgot-password-success-page" }}</a>544</div>545{{ template "auth_ui_footer.html" . }}546</div>547</body>548</html>549`,550}551var TemplateAuthUIResetPasswordHTML = template.Spec{552 Type: TemplateItemTypeAuthUIResetPasswordHTML,553 IsHTML: true,554 Translation: TemplateItemTypeAuthUITranslationJSON,555 Defines: defines,556 Components: components,557 Default: `<!DOCTYPE html>558<html>559{{ template "auth_ui_html_head.html" . }}560<body class="page">561<div class="content">562{{ template "auth_ui_header.html" . }}563<form class="simple-form vertical-form form-fields-container" method="post" novalidate>564{{ $.csrfField }}565<div class="title primary-txt">{{ localize "reset-password-page-title" }}</div>566{{ template "ERROR" . }}567<div class="description primary-txt">{{ localize "reset-password-description" }}</div>568<input id="password" data-password-policy-password="" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">569<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>570<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>571{{ template "PASSWORD_POLICY" . }}572<button class="btn primary-btn submit-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>573</form>574{{ template "auth_ui_footer.html" . }}575</div>576</body>577</html>578`,579}580var TemplateAuthUIResetPasswordSuccessHTML = template.Spec{581 Type: TemplateItemTypeAuthUIResetPasswordSuccessHTML,582 IsHTML: true,583 Translation: TemplateItemTypeAuthUITranslationJSON,584 Defines: defines,585 Components: components,586 Default: `<!DOCTYPE html>587<html>588{{ template "auth_ui_html_head.html" . }}589<body class="page">590<div class="content">591{{ template "auth_ui_header.html" . }}592<div class="simple-form vertical-form form-fields-container">593<div class="title primary-txt">{{ localize "reset-password-success-page-title" }}</div>594{{ template "ERROR" . }}595<div class="description primary-txt">{{ localize "reset-password-success-description" .x_login_id }}</div>596</div>597{{ template "auth_ui_footer.html" . }}598</div>599</body>600</html>601`,602}603var TemplateAuthUISignupHTML = template.Spec{604 Type: TemplateItemTypeAuthUISignupHTML,605 IsHTML: true,606 Translation: TemplateItemTypeAuthUITranslationJSON,607 Defines: defines,608 Components: components,609 Default: `<!DOCTYPE html>610<html>611{{ template "auth_ui_html_head.html" . }}612<body class="page">613 <div class="content">614 {{ template "auth_ui_header.html" . }}615 <div class="authorize-form">616 <div class="authorize-idp-section">617 {{ range .x_identity_candidates }}618 {{ if eq .type "oauth" }}619 <form class="authorize-idp-form" method="post" novalidate>620 {{ $.csrfField }}621 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">622 {{- if eq .provider_type "apple" -}}623 {{ localize "sign-up-apple" }}624 {{- end -}}625 {{- if eq .provider_type "google" -}}626 {{ localize "sign-up-google" }}627 {{- end -}}628 {{- if eq .provider_type "facebook" -}}629 {{ localize "sign-up-facebook" }}630 {{- end -}}631 {{- if eq .provider_type "linkedin" -}}632 {{ localize "sign-up-linkedin" }}633 {{- end -}}634 {{- if eq .provider_type "azureadv2" -}}635 {{ localize "sign-up-azureadv2" }}636 {{- end -}}637 </button>638 </form>639 {{ end }}640 {{ end }}641 </div>642 {{ $has_oauth := false }}643 {{ $has_login_id := false }}644 {{ range .x_identity_candidates }}645 {{ if eq .type "oauth" }}646 {{ $has_oauth = true }}647 {{ end }}648 {{ if eq .type "login_id" }}649 {{ $has_login_id = true }}650 {{ end }}651 {{ end }}652 {{ if $has_oauth }}{{ if $has_login_id }}653 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>654 {{ end }}{{ end }}655 {{ template "ERROR" . }}656 <form class="authorize-loginid-form" method="post" novalidate>657 {{ $.csrfField }}658 <input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">659 {{ range .x_identity_candidates }}660 {{ if eq .type "login_id" }}{{ if eq .login_id_key $.x_login_id_key }}661 {{ if eq .login_id_type "phone" }}662 <div class="phone-input">663 <select class="input select primary-txt" name="x_calling_code">664 {{ range $.x_calling_codes }}665 <option666 value="{{ . }}"667 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}668 selected669 {{ end }}{{ end }}670 >671 +{{ . }}672 </option>673 {{ end }}674 </select>675 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">676 </div>677 {{ else }}678 <input class="input text-input primary-txt" type="{{ $.x_login_id_input_type }}" name="x_login_id" placeholder="{{ .login_id_type }}">679 {{ end }}680 {{ end }}{{ end }}681 {{ end }}682 {{ range .x_identity_candidates }}683 {{ if eq .type "login_id" }}{{ if not (eq .login_id_key $.x_login_id_key) }}684 <a class="link align-self-flex-start"685 href="{{ call $.MakeURLWithQuery "x_login_id_key" .login_id_key "x_login_id_input_type" .login_id_input_type}}">686 {{ localize "use-login-id-key" .login_id_key }}687 </a>688 {{ end }}{{ end }}689 {{ end }}690 <div class="link align-self-flex-start">691 <span class="primary-text">{{ localize "login-button-hint" }}</span>692 <a href="{{ call .MakeURLWithPathWithoutX "/login" }}">{{ localize "login-button-label" }}</a>693 </div>694 {{ if .x_password_authenticator_enabled }}695 <a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label" }}</a>696 {{ end }}697 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">698 {{ localize "next-button-label" }}699 </button>700 </form>701 </div>702 {{ template "auth_ui_footer.html" . }}703 </div>704</body>705</html>706`,707}708var TemplateAuthUIPromoteHTML = template.Spec{709 Type: TemplateItemTypeAuthUIPromoteHTML,710 IsHTML: true,711 Translation: TemplateItemTypeAuthUITranslationJSON,712 Defines: defines,713 Components: components,714 Default: `<!DOCTYPE html>715<html>716{{ template "auth_ui_html_head.html" . }}717<body class="page">718 <div class="content">719 {{ template "auth_ui_header.html" . }}720 <div class="authorize-form">721 <div class="authorize-idp-section">722 {{ range .x_identity_candidates }}723 {{ if eq .type "oauth" }}724 <form class="authorize-idp-form" method="post" novalidate>725 {{ $.csrfField }}726 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">727 {{- if eq .provider_type "apple" -}}728 {{ localize "sign-up-apple" }}729 {{- end -}}730 {{- if eq .provider_type "google" -}}731 {{ localize "sign-up-google" }}732 {{- end -}}733 {{- if eq .provider_type "facebook" -}}734 {{ localize "sign-up-facebook" }}735 {{- end -}}736 {{- if eq .provider_type "linkedin" -}}737 {{ localize "sign-up-linkedin" }}738 {{- end -}}739 {{- if eq .provider_type "azureadv2" -}}740 {{ localize "sign-up-azureadv2" }}741 {{- end -}}742 </button>743 </form>744 {{ end }}745 {{ end }}746 </div>747 {{ $has_oauth := false }}748 {{ $has_login_id := false }}749 {{ range .x_identity_candidates }}750 {{ if eq .type "oauth" }}751 {{ $has_oauth = true }}752 {{ end }}753 {{ if eq .type "login_id" }}754 {{ $has_login_id = true }}755 {{ end }}756 {{ end }}757 {{ if $has_oauth }}{{ if $has_login_id }}758 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>759 {{ end }}{{ end }}760 {{ template "ERROR" . }}761 <form class="authorize-loginid-form" method="post" novalidate>762 {{ $.csrfField }}763 <input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">764 {{ range .x_identity_candidates }}765 {{ if eq .type "login_id" }}{{ if eq .login_id_key $.x_login_id_key }}766 {{ if eq .login_id_type "phone" }}767 <div class="phone-input">768 <select class="input select primary-txt" name="x_calling_code">769 {{ range $.x_calling_codes }}770 <option771 value="{{ . }}"772 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}773 selected774 {{ end }}{{ end }}775 >776 +{{ . }}777 </option>778 {{ end }}779 </select>780 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">781 </div>782 {{ else }}783 <input class="input text-input primary-txt" type="{{ $.x_login_id_input_type }}" name="x_login_id" placeholder="{{ .login_id_type }}">784 {{ end }}785 {{ end }}{{ end }}786 {{ end }}787 {{ range .x_identity_candidates }}788 {{ if eq .type "login_id" }}{{ if not (eq .login_id_key $.x_login_id_key) }}789 <a class="link align-self-flex-start"790 href="{{ call $.MakeURLWithQuery "x_login_id_key" .login_id_key "x_login_id_input_type" .login_id_input_type}}">791 {{ localize "use-login-id-key" .login_id_key }}792 </a>793 {{ end }}{{ end }}794 {{ end }}795 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">796 {{ localize "next-button-label" }}797 </button>798 </form>799 </div>800 {{ template "auth_ui_footer.html" . }}801 </div>802</body>803</html>804`,805}806var TemplateAuthUICreatePasswordHTML = template.Spec{807 Type: TemplateItemTypeAuthUICreatePasswordHTML,808 IsHTML: true,809 Translation: TemplateItemTypeAuthUITranslationJSON,810 Defines: defines,811 Components: components,812 Default: `<!DOCTYPE html>813<html>814{{ template "auth_ui_html_head.html" . }}815<body class="page">816<div class="content">817{{ template "auth_ui_header.html" . }}818<form class="simple-form vertical-form form-fields-container" method="post" novalidate>819{{ $.csrfField }}820<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">821<div class="nav-bar">822 <button class="btn back-btn" type="button" title="{{ "back-button-title" }}"></button>823 <div class="login-id primary-txt">824 {{ if .x_national_number }}825 +{{ .x_calling_code}} {{ .x_national_number }}826 {{ else }}827 {{ .x_login_id }}828 {{ end }}829 </div>830</div>831<div class="title primary-txt">{{ localize "create-password-page-title" }}</div>832{{ template "ERROR" . }}833<input id="password" data-password-policy-password="" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">834<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>835<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>836{{ template "PASSWORD_POLICY" . }}837<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>838{{ if eq .x_login_id_input_type "phone" }}839<p class="secondary-txt description">840{{ localize "sms-charge-warning" }}841</p>842{{ end }}843</form>844{{ template "auth_ui_footer.html" . }}845</div>846</body>847</html>848`,849}850var TemplateAuthUISettingsHTML = template.Spec{851 Type: TemplateItemTypeAuthUISettingsHTML,852 IsHTML: true,853 Translation: TemplateItemTypeAuthUITranslationJSON,854 Defines: defines,855 Components: components,856 Default: `<!DOCTYPE html>857<html>858{{ template "auth_ui_html_head.html" . }}859<body class="page">860<div class="content">861{{ template "auth_ui_header.html" . }}862<div class="settings-form primary-txt">863 You are authenticated. To logout, please visit <a href="/logout">here</a>.864</div>865{{ template "auth_ui_footer.html" . }}866</div>867</body>868</html>869`,870}871var TemplateAuthUISettingsIdentityHTML = template.Spec{872 Type: TemplateItemTypeAuthUISettingsIdentityHTML,873 IsHTML: true,874 Translation: TemplateItemTypeAuthUITranslationJSON,875 Defines: defines,876 Components: components,877 Default: `<!DOCTYPE html>878<html>879{{ template "auth_ui_html_head.html" . }}880<body class="page">881<div class="content">882{{ template "auth_ui_header.html" . }}883<div class="settings-identity">884 <h1 class="title primary-txt">{{ localize "settings-identity-title" }}</h1>885 {{ template "ERROR" . }}886 {{ range .x_identity_candidates }}887 <div class="identity">888 <div class="icon {{ .type }} {{ .provider_type }} {{ .login_id_type }}"></div>889 <div class="identity-info flex-child-no-overflow">890 <h2 class="identity-name primary-txt">891 {{ if eq .type "oauth" }}892 {{ if eq .provider_type "google" }}893 {{ localize "settings-identity-oauth-google" }}894 {{ end }}895 {{ if eq .provider_type "apple" }}896 {{ localize "settings-identity-oauth-apple" }}897 {{ end }}898 {{ if eq .provider_type "facebook" }}899 {{ localize "settings-identity-oauth-facebook" }}900 {{ end }}901 {{ if eq .provider_type "linkedin" }}902 {{ localize "settings-identity-oauth-linkedin" }}903 {{ end }}904 {{ if eq .provider_type "azureadv2" }}905 {{ localize "settings-identity-oauth-azureadv2" }}906 {{ end }}907 {{ end }}908 {{ if eq .type "login_id" }}909 {{ if eq .login_id_type "email" }}910 {{ localize "settings-identity-login-id-email" }}911 {{ end }}912 {{ if eq .login_id_type "phone" }}913 {{ localize "settings-identity-login-id-phone" }}914 {{ end }}915 {{ if eq .login_id_type "username" }}916 {{ localize "settings-identity-login-id-username" }}917 {{ end }}918 {{ if eq .login_id_type "raw" }}919 {{ localize "settings-identity-login-id-raw" }}920 {{ end }}921 {{ end }}922 </h2>923 {{ if eq .type "oauth" }}{{ if .email }}924 <h3 class="identity-claim secondary-txt text-ellipsis">925 {{ .email }}926 </h3>927 {{ end }}{{ end }}928 {{ if eq .type "login_id" }}{{ if .login_id_value }}929 <h3 class="identity-claim secondary-txt text-ellipsis">930 {{ .login_id_value }}931 </h3>932 {{ end }}{{ end }}933 </div>934 {{ if eq .type "oauth" }}935 <form method="post" novalidate>936 {{ $.csrfField }}937 <input type="hidden" name="x_idp_id" value="{{ .provider_alias }}">938 {{ if .provider_subject_id }}939 <button class="btn destructive-btn" type="submit" name="x_action" value="unlink">{{ localize "disconnect-button-label" }}</button>940 {{ else }}941 <button class="btn primary-btn" type="submit" name="x_action" value="link" data-form-xhr="false">{{ localize "connect-button-label" }}</button>942 {{ end }}943 </form>944 {{ end }}945 {{ if eq .type "login_id" }}946 <form method="post" novalidate>947 {{ $.csrfField }}948 <input type="hidden" name="x_login_id_key" value="{{ .login_id_key }}">949 <input type="hidden" name="x_login_id_type" value="{{ .login_id_type }}">950 {{ if eq .login_id_type "phone" }}951 <input type="hidden" name="x_login_id_input_type" value="phone">952 {{ else if eq .login_id_type "email" }}953 <input type="hidden" name="x_login_id_input_type" value="email">954 {{ else }}955 <input type="hidden" name="x_login_id_input_type" value="text">956 {{ end }}957 {{ if .login_id_value }}958 <input type="hidden" name="x_old_login_id_value" value="{{ .login_id_value }}">959 <button class="btn secondary-btn" type="submit" name="x_action" value="login_id">{{ localize "change-button-label" }}</a>960 {{ else }}961 <button class="btn primary-btn" type="submit" name="x_action" value="login_id">{{ localize "connect-button-label" }}</a>962 {{ end }}963 </form>964 {{ end }}965 </div>966 {{ end }}967</div>968{{ template "auth_ui_footer.html" . }}969</div>970</body>971</html>972`,973}974var TemplateAuthUILogoutHTML = template.Spec{975 Type: TemplateItemTypeAuthUILogoutHTML,976 IsHTML: true,977 Translation: TemplateItemTypeAuthUITranslationJSON,978 Defines: defines,979 Components: components,980 Default: `<!DOCTYPE html>981<html>982{{ template "auth_ui_html_head.html" . }}983<body class="page">984<div class="content">985{{ template "auth_ui_header.html" . }}986<form class="logout-form" method="post" novalidate>987 {{ $.csrfField }}988 <p class="primary-txt">{{ localize "logout-button-hint" }}</p>989 <button class="btn primary-btn align-self-center" type="submit" name="x_action" value="logout">{{ localize "logout-button-label" }}</button>990</form>991{{ template "auth_ui_footer.html" . }}992</div>993</body>994</html>995`,996}...

Full Screen

Full Screen

App.go

Source:App.go Github

copy

Full Screen

1package main2import (3 "database/sql"4 "fmt"5 "html/template"6 "log"7 "net/http"8 _ "github.com/go-sql-driver/mysql"9 "github.com/gorilla/mux"10 "tawesoft.co.uk/go/dialog"11)12type Employee struct {13 Name string14 Password string15 Id int16}17func dbConn() (db *sql.DB) {18 db, err := sql.Open("mysql", "root:Qazxsw#2!@tcp(localhost:3306)/users")19 if err != nil {20 fmt.Println("error validating sql.opem arguments")21 panic(err.Error())22 }23 //defer db.Close()24 err = db.Ping()25 if err != nil {26 fmt.Println("error verifying connection with db.ping")27 panic(err.Error())28 } else {29 fmt.Println("sucess")30 }31 return db32}33var t = template.Must(template.ParseGlob("*.html"))34//var t = template.Must(template.New("html-tmpl").ParseGlob("*.tmpl"))35func login(w http.ResponseWriter, r *http.Request) {36 t.ExecuteTemplate(w, "login.html", nil)37}38/////////////-POST user39func postUser(w http.ResponseWriter, r *http.Request) {40 fmt.Println("inside postUser")41 Username := r.FormValue("username")42 Password := r.FormValue("password")43 db := dbConn()44 fmt.Println("username " + Username)45 fmt.Println("password" + Password)46 fmt.Println("inside postUser after dbconn")47 ///validation using input48 if Username == "" {49 dialog.Alert("EMpty Username")50 http.Redirect(w, r, "/login", 301)51 return52 }53 if len(Password) < 8 {54 dialog.Alert("Minimum Length should be 8")55 http.Redirect(w, r, "/login", 301)56 return57 }58 fmt.Println(len(Password))59 insert, err := db.Prepare("INSERT INTO `users`.`emp` VALUES (?,?,NULL)")60 if err != nil {61 fmt.Println("inside PostError")62 panic(err.Error())63 }64 insert.Exec(Username, Password)65 defer insert.Close()66 defer db.Close()67 dialog.Alert("Posted USER")68 http.Redirect(w, r, "/login", 301)69}70//////////->GET user71func getUser(w http.ResponseWriter, r *http.Request) {72 parsedTemplate, _ := template.ParseFiles("index.html")73 fmt.Println("inside getUser")74 db := dbConn()75 fmt.Println("inside getuser after dbconn")76 nId := r.FormValue("username")77 selDB, err := db.Query("SELECT * FROM emp WHERE name=?", nId)78 if err != nil {79 panic(err.Error())80 }81 employ := Employee{}82 res := []Employee{}83 for selDB.Next() {84 var name string85 var password string86 var id int87 err = selDB.Scan(&name, &password, &id)88 if err != nil {89 panic(err.Error())90 }91 employ.Name = name92 employ.Password = password93 employ.Id = id94 res = append(res, employ)95 }96 if len(employ.Name) == 0 {97 fmt.Fprintf(w, "no details")98 return99 }100 fmt.Println(res)101 fmt.Println("hi")102 //t.ExecuteTemplate(w, "index.html", res)103 errr := parsedTemplate.Execute(w, res)104 if errr != nil {105 fmt.Println("inside the p error")106 panic(errr.Error())107 }108 defer selDB.Close()109 defer db.Close()110}111/////////->DELETE user112func deleteUser(w http.ResponseWriter, r *http.Request) {113 fmt.Println("inside deleteUser")114 db := dbConn()115 fmt.Println("inside deleteuser after dbconn")116 Username := r.FormValue("username")117 fmt.Println(Username)118 delete, err := db.Prepare("DELETE FROM emp WHERE name= ?")119 if err != nil {120 panic(err.Error())121 }122 delete.Exec(Username)123 dialog.Alert("DELETED USER")124 http.Redirect(w, r, "/login", 301)125 defer db.Close()126}127////->UPDATE user128func updateUser(w http.ResponseWriter, r *http.Request) {129 fmt.Println("inside deleteUser")130 db := dbConn()131 fmt.Println("inside deleteuser after dbconn")132 Username := r.FormValue("username")133 Password := r.FormValue("password")134 fmt.Println(Username)135 fmt.Println(Password)136 update, err := db.Prepare("UPDATE emp SET password=? WHERE name=?")137 if err != nil {138 panic(err.Error())139 }140 update.Exec(Password, Username)141 dialog.Alert("Updated USER")142 defer db.Close()143 http.Redirect(w, r, "/login", 301)144}145///////////->SHOW USER146func showUser(w http.ResponseWriter, r *http.Request) {147 parsedTemplate, _ := template.ParseFiles("index.html")148 fmt.Println("inside showUser")149 db := dbConn()150 fmt.Println("inside showuser after dbconn")151 selDB, err := db.Query("SELECT * FROM emp ")152 if err != nil {153 panic(err.Error())154 }155 employ := Employee{}156 res := []Employee{}157 for selDB.Next() {158 var name string159 var password string160 var id int161 //selDB.Scan(&\)162 err = selDB.Scan(&name, &password, &id)163 if err != nil {164 panic(err.Error())165 }166 employ.Name = name167 employ.Password = password168 employ.Id = id169 res = append(res, employ)170 }171 if len(employ.Name) == 0 {172 fmt.Fprintf(w, "no details")173 return174 }175 fmt.Println(res)176 fmt.Println("hi")177 errr := parsedTemplate.Execute(w, res)178 if errr != nil {179 fmt.Println("inside the p error")180 panic(errr.Error())181 }182 defer selDB.Close()183 defer db.Close()184}185////////->VALIDATE USER186func validate(w http.ResponseWriter, r *http.Request) {187 fmt.Println("inside validateUser")188 db := dbConn()189 fmt.Println("inside validateuser after dbconn")190 Username := r.FormValue("username")191 Password := r.FormValue("password")192 valDb, err := db.Prepare("SELECT * FROM emp WHERE name=? AND password=?")193 if err != nil {194 panic(err.Error())195 }196 fmt.Println("username is:" + Username)197 fmt.Println("password is:" + Password)198 //valDb.Exec(Username, Password)199 fmt.Println(valDb)200 employ := Employee{}201 var name string202 var password string203 var id int204 errr := valDb.QueryRow(Username, Password).Scan(&name, &password, &id)205 if errr != nil {206 if errr == sql.ErrNoRows {207 }208 }209 employ.Name = name210 employ.Password = password211 employ.Id = id212 fmt.Println("Inside errr")213 fmt.Println("the data name is" + employ.Name)214 fmt.Println("the data password is" + employ.Password)215 if name == "" {216 fmt.Println("INVALID USER")217 dialog.Alert("INVALID USER")218 defer valDb.Close()219 defer db.Close()220 http.Redirect(w, r, "/login", 301)221 return222 }223 dialog.Alert("VALID USER")224 http.Redirect(w, r, "/login", 301)225 defer valDb.Close()226 defer db.Close()227}228///////////229func novalidate(w http.ResponseWriter, r *http.Request) {230 fmt.Println("inside novalidateUser")231 db := dbConn()232 fmt.Println("inside novalidateuser after dbconn")233 Username := r.FormValue("username")234 Password := r.FormValue("password")235 valDb, err := db.Prepare("SELECT * FROM emp WHERE name='" + Username + "' AND password='" + Password + "'")236 if err != nil {237 // panic(err.Error())238 }239 fmt.Println("username is:" + Username)240 fmt.Println("password is:" + Password)241 fmt.Println(valDb)242 employ := Employee{}243 var name string244 var password string245 var id int246 valDb.QueryRow().Scan(&name, &password, &id)247 employ.Name = name248 employ.Password = password249 employ.Id = id250 fmt.Println("Inside errr")251 fmt.Println("the data name is" + employ.Name)252 fmt.Println("the data password is" + employ.Password)253 if name == "" {254 fmt.Println("INVALID USER")255 dialog.Alert("INVALID USER")256 defer valDb.Close()257 defer db.Close()258 http.Redirect(w, r, "/login", 301)259 return260 }261 dialog.Alert("VALID USER")262 http.Redirect(w, r, "/login", 301)263 defer valDb.Close()264 defer db.Close()265}266func main() {267 r := mux.NewRouter()268 //dbConn()269 r.HandleFunc("/postUser", postUser).Methods("POST")270 r.HandleFunc("/getUser", getUser).Methods("POST")271 r.HandleFunc("/deleteUser", deleteUser).Methods("POST")272 r.HandleFunc("/updateUser", updateUser).Methods("POST")273 r.HandleFunc("/showUser", showUser).Methods("POST")274 r.HandleFunc("/validate", validate).Methods(("POST"))275 r.HandleFunc("/novalidate", novalidate).Methods(("POST"))276 r.HandleFunc("/login", login)277 errr := http.ListenAndServe(":9090", r) // setting listening port278 if errr != nil {279 log.Fatal("ListenAndServe: ", errr)280 }281}...

Full Screen

Full Screen

html_form.go

Source:html_form.go Github

copy

Full Screen

...61func (e *HTMLForm) Name(v string) *HTMLForm {62 e.a["name"] = v63 return e64}65// NoValidate sets the element's "novalidate" attribute66func (e *HTMLForm) NoValidate(v bool) *HTMLForm {67 if v {68 e.a["novalidate"] = ""69 } else {70 delete(e.a, "novalidate")71 }72 return e73}74// Target sets the element's "target" attribute75func (e *HTMLForm) Target(v string) *HTMLForm {76 e.a["target"] = v77 return e78}79// CheckValidity sets the element's "checkvalidity" attribute80func (e *HTMLForm) CheckValidity(v bool) *HTMLForm {...

Full Screen

Full Screen

NoValidate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {4 fmt.Fprintf(w, "Hello, %q", html.NoValidate)5 })6 http.ListenAndServe(":8080", nil)7}

Full Screen

Full Screen

NoValidate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<script>alert('you have been pwned')</script>"))4 fmt.Println(html.UnescapeString("&lt;script&gt;alert(&#39;you have been pwned&#39;)&lt;/script&gt;"))5 fmt.Println(html.EscapeString("This is a test & This is a test"))6 fmt.Println(html.UnescapeString("This is a test &amp; This is a test"))7 fmt.Println(html.UnescapeString("This is a test & This is a test"))8}

Full Screen

Full Screen

NoValidate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.NoValidate)4}5import (6func main() {7 fmt.Println(html.Nonce("abc"))8}9import (10func main() {11 fmt.Println(html.Not)12}13import (14func main() {15 fmt.Println(html.Number)16}17import (18func main() {19 fmt.Println(html.Object)20}21import (22func main() {23 fmt.Println(html.Onbeforecopy)24}25import (26func main() {27 fmt.Println(html.Onbeforecut)28}29import (30func main() {31 fmt.Println(html.Onbeforepaste)32}33import (34func main() {35 fmt.Println(html.Onblur)36}37import (38func main() {39 fmt.Println(html.Onchange)40}41import (42func main() {43 fmt.Println(html.Onclick)44}45import (46func main() {47 fmt.Println(html.Ondblclick)48}

Full Screen

Full Screen

NoValidate

Using AI Code Generation

copy

Full Screen

1import (2var decoder = schema.NewDecoder()3func main() {4 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {5 decoder.IgnoreUnknownKeys(true)6 err := r.ParseForm()7 if err != nil {8 panic(err)9 }10 fmt.Fprintf(w, "%v\n", r.PostForm)11 fmt.Fprintf(w, "%v\n", r.PostFormValue("name"))12 fmt.Fprintf(w, "%v\n", r.PostFormValue("age"))13 fmt.Fprintf(w, "%v\n", r.PostFormValue("location"))14 fmt.Fprintf(w, "%v\n", r.PostFormValue("email"))15 })16 http.ListenAndServe(":8080", nil)17}18import (19var decoder = schema.NewDecoder()20func main() {21 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {22 decoder.IgnoreUnknownKeys(true)23 err := r.ParseForm()24 if err != nil {25 panic(err)26 }27 fmt.Fprintf(w, "%v\n", r.PostForm)28 fmt.Fprintf(w, "%v\n", r.PostFormValue("name"))29 fmt.Fprintf(w, "%v\n", r.PostFormValue("age"))30 fmt.Fprintf(w, "%v\n", r.PostFormValue("location"))31 fmt.Fprintf(w, "%v\n", r.PostFormValue("email"))32 })33 http.ListenAndServe(":8080", nil)34}35import (36var decoder = schema.NewDecoder()37func main() {38 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {39 decoder.IgnoreUnknownKeys(true)40 err := r.ParseForm()41 if err != nil {42 panic(err)43 }44 fmt.Fprintf(w, "%v\n", r.PostForm)45 fmt.Fprintf(w, "%v\n", r.PostFormValue("name"))46 fmt.Fprintf(w, "%v\n", r.PostFormValue("age"))47 fmt.Fprintf(w, "%v\n

Full Screen

Full Screen

NoValidate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 var s = "<script>alert('Hello World!')</script>"4 fmt.Println(html.EscapeString(s))5 fmt.Println(html.UnescapeString(s))6 fmt.Println(html.EscapeString("hello world"))7 fmt.Println(html.UnescapeString("hello world"))8 fmt.Println(html.NoEscapeString("hello world"))9 fmt.Println(html.UnescapeString("hello world"))10}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful