web/satellite: Remove activated account page
Error message for attempting to activate an already-activated account is removed from its own page and incorporated into the login page in an identical manner to the message that appears upon successful activation. Change-Id: I29cd2685a7808fa71d34a439c86a38eb5fc3e199
This commit is contained in:
parent
ae345320fe
commit
615aae6bdd
@ -160,7 +160,6 @@ type Server struct {
|
||||
usageReport *template.Template
|
||||
resetPassword *template.Template
|
||||
success *template.Template
|
||||
activated *template.Template
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,7 +558,7 @@ func (server *Server) accountActivationHandler(w http.ResponseWriter, r *http.Re
|
||||
zap.Error(err))
|
||||
|
||||
if console.ErrEmailUsed.Has(err) {
|
||||
server.serveError(w, http.StatusConflict)
|
||||
http.Redirect(w, r, server.config.ExternalAddress+"login?activated=false", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
|
||||
@ -767,11 +766,6 @@ func (server *Server) serveError(w http.ResponseWriter, status int) {
|
||||
if err != nil {
|
||||
server.log.Error("cannot parse pageNotFound template", zap.Error(Error.Wrap(err)))
|
||||
}
|
||||
case http.StatusConflict:
|
||||
err := server.templates.activated.Execute(w, nil)
|
||||
if err != nil {
|
||||
server.log.Error("cannot parse already activated template", zap.Error(Error.Wrap(err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,11 +821,6 @@ func (server *Server) initializeTemplates() (err error) {
|
||||
server.log.Error("dist folder is not generated. use 'npm run build' command", zap.Error(err))
|
||||
}
|
||||
|
||||
server.templates.activated, err = template.ParseFiles(filepath.Join(server.config.StaticDir, "static", "activation", "activated.html"))
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
server.templates.success, err = template.ParseFiles(filepath.Join(server.config.StaticDir, "static", "resetPassword", "success.html"))
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
|
60
satellite/console/consoleweb/server_test.go
Normal file
60
satellite/console/consoleweb/server_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package consoleweb_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite/console"
|
||||
)
|
||||
|
||||
func TestActivationRouting(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 0,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
sat := planet.Satellites[0]
|
||||
service := sat.API.Console.Service
|
||||
|
||||
regToken, err := service.CreateRegToken(ctx, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
user, err := service.CreateUser(ctx, console.CreateUser{
|
||||
FullName: "User",
|
||||
Email: "u@mail.test",
|
||||
Password: "123a123",
|
||||
}, regToken.Secret)
|
||||
require.NoError(t, err)
|
||||
|
||||
activationToken, err := service.GenerateActivationToken(ctx, user.ID, user.Email)
|
||||
require.NoError(t, err)
|
||||
|
||||
checkActivationRedirect := func(testMsg, redirectURL string) {
|
||||
url := "http://" + sat.API.Console.Listener.Addr().String() + "/activation/?token=" + activationToken
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody)
|
||||
require.NoError(t, err, testMsg)
|
||||
|
||||
result, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err, testMsg)
|
||||
|
||||
require.Equal(t, http.StatusTemporaryRedirect, result.StatusCode, testMsg)
|
||||
require.Equal(t, redirectURL, result.Header.Get("Location"), testMsg)
|
||||
require.NoError(t, result.Body.Close(), testMsg)
|
||||
}
|
||||
|
||||
http.DefaultClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
|
||||
loginURL := "http://" + sat.API.Console.Listener.Addr().String() + "/login"
|
||||
|
||||
checkActivationRedirect("Activation - Fresh Token", loginURL+"?activated=true")
|
||||
checkActivationRedirect("Activation - Used Token", loginURL+"?activated=false")
|
||||
})
|
||||
}
|
@ -8,8 +8,11 @@
|
||||
</div>
|
||||
<div class="login-area__content-area">
|
||||
<div class="login-area__content-area">
|
||||
<div class="login-area__content-area__activation-banner" v-if="isActivatedBannerShown">
|
||||
<p class="login-area__content-area__activation-banner__message"><b>Success!</b> Account Verified.</p>
|
||||
<div class="login-area__content-area__activation-banner" :class="{'error': isActivatedError}" v-if="isActivatedBannerShown">
|
||||
<p class="login-area__content-area__activation-banner__message">
|
||||
<template v-if="!isActivatedError"><b>Success!</b> Account verified.</template>
|
||||
<template v-else><b>Oops!</b> This account has already been verified.</template>
|
||||
</p>
|
||||
</div>
|
||||
<div class="login-area__content-area__container">
|
||||
<div class="login-area__content-area__container__title-area">
|
||||
@ -105,6 +108,7 @@ export default class Login extends Vue {
|
||||
|
||||
public readonly forgotPasswordPath: string = RouteConfig.ForgotPassword.path;
|
||||
public isActivatedBannerShown: boolean = false;
|
||||
public isActivatedError: boolean = false;
|
||||
|
||||
// Tardigrade logic
|
||||
public isDropdownShown: boolean = false;
|
||||
@ -116,9 +120,8 @@ export default class Login extends Vue {
|
||||
* Makes activated banner visible on successful account activation.
|
||||
*/
|
||||
public mounted(): void {
|
||||
if (this.$route.query.activated === 'true') {
|
||||
this.isActivatedBannerShown = true;
|
||||
}
|
||||
this.isActivatedBannerShown = !!this.$route.query.activated;
|
||||
this.isActivatedError = this.$route.query.activated === 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -337,14 +340,20 @@ export default class Login extends Vue {
|
||||
padding: 20px;
|
||||
background-color: rgba(39, 174, 96, 0.1);
|
||||
border: 1px solid #27ae60;
|
||||
color: #27ae60;
|
||||
border-radius: 6px;
|
||||
width: 570px;
|
||||
margin-bottom: 30px;
|
||||
|
||||
&.error {
|
||||
background-color: #fff3f2;
|
||||
border: 1px solid #e30011;
|
||||
color: #e30011;
|
||||
}
|
||||
|
||||
&__message {
|
||||
font-size: 16px;
|
||||
line-height: 21px;
|
||||
color: #27ae60;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* Copyright (C) 2019 Storj Labs, Inc. */
|
||||
/* See LICENSE for copying information. */
|
||||
|
||||
.container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.container__title {
|
||||
font-family: 'font_regular', sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 32px;
|
||||
line-height: 39px;
|
||||
margin: 24px 0 24px 0;
|
||||
color: #384b65;
|
||||
}
|
||||
|
||||
.container__info {
|
||||
width: 566px;
|
||||
text-align: center;
|
||||
font-family: 'font_regular', sans-serif;
|
||||
font-size: 18px;
|
||||
line-height: 26px;
|
||||
margin: 0;
|
||||
color: #354049;
|
||||
}
|
||||
|
||||
.container__button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #2683ff;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
width: 216px;
|
||||
height: 48px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.container__button p {
|
||||
font-family: 'font_regular', sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
line-height: 23px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.container__button:hover {
|
||||
background-color: #0059d0;
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user