Skip to content

Commit d38c402

Browse files
committed
fix(be): remove unused auth method
1 parent 87a1c53 commit d38c402

File tree

4 files changed

+6
-117
lines changed

4 files changed

+6
-117
lines changed

api/auth_verify.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,3 @@ func sendEmailVerificationCode(code string, email string) error {
112112

113113
return err
114114
}
115-
116-
func startEmailVerification(w http.ResponseWriter, r *http.Request) {
117-
if !util.Config.Auth.Email.Enabled {
118-
helpers.WriteErrorStatus(w, "EMAIL_VERIFICATION_DISABLED", http.StatusForbidden)
119-
return
120-
}
121-
122-
session, ok := getSession(r)
123-
124-
if !ok {
125-
w.WriteHeader(http.StatusUnauthorized)
126-
return
127-
}
128-
129-
store := helpers.Store(r)
130-
131-
user, err := store.GetUser(session.UserID)
132-
if err != nil {
133-
helpers.WriteError(w, err)
134-
return
135-
}
136-
137-
code := util.RandString(16)
138-
139-
err = sendEmailVerificationCode(code, user.Email)
140-
if err != nil {
141-
helpers.WriteError(w, err)
142-
return
143-
}
144-
}

api/login_email.go

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package api
22

33
import (
4-
"errors"
4+
"net/http"
5+
56
"github.com/semaphoreui/semaphore/api/helpers"
67
"github.com/semaphoreui/semaphore/db"
78
"github.com/semaphoreui/semaphore/pkg/random"
89
log "github.com/sirupsen/logrus"
9-
"net/http"
1010
)
1111

1212
func newEmailOtp(userID int, userEmail string, store db.Store) error {
@@ -46,47 +46,3 @@ func resendEmailOtp(w http.ResponseWriter, r *http.Request) {
4646
return
4747
}
4848
}
49-
50-
func loginEmail(w http.ResponseWriter, r *http.Request) {
51-
52-
var email struct {
53-
Email string `json:"email" binding:"required"`
54-
}
55-
if !helpers.Bind(w, r, &email) {
56-
return
57-
}
58-
59-
store := helpers.Store(r)
60-
61-
user, err := store.GetUserByLoginOrEmail("", email.Email)
62-
63-
if err != nil {
64-
if errors.Is(err, db.ErrNotFound) {
65-
user, err = store.CreateUserWithoutPassword(db.User{
66-
Email: email.Email,
67-
External: true,
68-
Alert: true,
69-
Pro: true,
70-
Name: getRandomProfileName(),
71-
Username: getRandomUsername(),
72-
})
73-
} else {
74-
var validationError *db.ValidationError
75-
switch {
76-
case errors.As(err, &validationError):
77-
// TODO: Return more informative error code.
78-
}
79-
80-
log.WithError(err).WithFields(log.Fields{
81-
"email": email.Email,
82-
"context": "loginEmail",
83-
}).Error("Failed to get or create user by email")
84-
w.WriteHeader(http.StatusInternalServerError)
85-
return
86-
}
87-
}
88-
89-
createSession(w, r, user, false)
90-
91-
w.WriteHeader(http.StatusNoContent)
92-
}

api/router.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ func Route(
144144
publicAPIRouter.Use(StoreMiddleware, JSONMiddleware)
145145

146146
publicAPIRouter.HandleFunc("/auth/login", login).Methods("GET", "POST")
147-
publicAPIRouter.HandleFunc("/auth/verify/email", startEmailVerification).Methods("POST")
148-
publicAPIRouter.HandleFunc("/auth/login/email", loginEmail).Methods("GET", "POST")
149147
publicAPIRouter.HandleFunc("/auth/login/email/resend", resendEmailOtp).Methods("GET", "POST")
150148
publicAPIRouter.HandleFunc("/auth/verify", verifySession).Methods("POST")
151149
publicAPIRouter.HandleFunc("/auth/recovery", recoverySession).Methods("POST")

web/src/views/Auth.vue

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -224,48 +224,13 @@
224224
{{ $t('signIn') }}
225225
</v-btn>
226226

227-
</div>
227+
<div
228+
class="auth__divider"
229+
v-if="oidcProviders.length > 0"
230+
>or</div>
228231

229-
<div v-else>
230-
<v-text-field
231-
v-model="email"
232-
:label="$t('Email')"
233-
:rules="[v => !!v || $t('email_required')]"
234-
type="email"
235-
required
236-
:disabled="signInProcess"
237-
@keyup.enter.native="signInWithEmail"
238-
style="margin-bottom: 20px;"
239-
data-testid="auth-password"
240-
outlined
241-
class="mb-0"
242-
></v-text-field>
243-
244-
<v-btn
245-
large
246-
color="primary"
247-
@click="signInWithEmail"
248-
:disabled="signInProcess"
249-
block
250-
rounded
251-
data-testid="auth-signin-with-eamil"
252-
>
253-
<v-icon
254-
left
255-
dark
256-
>
257-
mdi-email
258-
</v-icon>
259-
260-
{{ $t('Continue with Email') }}
261-
</v-btn>
262232
</div>
263233

264-
<div
265-
class="auth__divider"
266-
v-if="oidcProviders.length > 0"
267-
>or</div>
268-
269234
<v-btn
270235
large
271236
v-for="provider in oidcProviders"

0 commit comments

Comments
 (0)