Skip to content

UX of link account (Step 1) #5006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sign_in = Sign In
sign_in_with = Sign In With
sign_out = Sign Out
sign_up = Register
add_recovery = Add Email and Password (for Account Recovery)
link_account = Link Account
link_account_signin_or_signup = Sign in with existing credentials to link your existing account to this account. Or register a new one.
register = Register
Expand Down
19 changes: 17 additions & 2 deletions routers/user/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,23 @@ func LinkAccount(ctx *context.Context) {
return
}

ctx.Data["user_name"] = gothUser.(goth.User).NickName
ctx.Data["email"] = gothUser.(goth.User).Email
uname := gothUser.(goth.User).NickName
email := gothUser.(goth.User).Email
ctx.Data["user_name"] = uname
ctx.Data["email"] = email

if "" != uname {
u, _ := models.GetUserByName(uname)
if u != nil {
ctx.Data["user_name_exists"] = "true"
}
}
if "" != email {
u, _ := models.GetUserByEmail(email)
if u != nil {
ctx.Data["email_exists"] = "true"
}
}

ctx.HTML(200, tplLinkAccount)
}
Expand Down
5 changes: 5 additions & 0 deletions templates/user/auth/link_account.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
</div>
</div>
</div>

{{if or .user_name_exists .email_exists}}
<div class="ui user signin container icon">
{{template "user/auth/signin_inner" .}}
</div>
{{else}}
{{template "user/auth/signup_inner" .}}
{{end}}

{{template "base/footer" .}}
6 changes: 5 additions & 1 deletion templates/user/auth/signup_inner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<form class="ui form" action="{{.SignUpLink}}" method="post">
{{.CsrfTokenHtml}}
<h3 class="ui top attached header">
{{.i18n.Tr "sign_up"}}
{{if .LinkAccountMode}}
{{.i18n.Tr "add_recovery"}}
{{else}}
{{.i18n.Tr "sign_up"}}
{{end}}
</h3>
<div class="ui attached segment">
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister)}}
Expand Down