diff --git a/api/v1/auth.go b/api/v1/auth.go index 9699251be6496..ae15300b2b0a6 100644 --- a/api/v1/auth.go +++ b/api/v1/auth.go @@ -117,9 +117,6 @@ func (s *APIV1Service) SignIn(c echo.Context) error { if err := s.UpsertAccessTokenToStore(ctx, user, accessToken); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to upsert access token, err: %s", err)).SetInternal(err) } - if err := s.CreateAuthSignInActivity(c, user); err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) - } cookieExp := time.Now().Add(auth.CookieExpDuration) setTokenCookie(c, auth.AccessTokenCookieName, accessToken, cookieExp) userMessage := convertUserFromStore(user) @@ -241,9 +238,6 @@ func (s *APIV1Service) SignInSSO(c echo.Context) error { if err := s.UpsertAccessTokenToStore(ctx, user, accessToken); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to upsert access token, err: %s", err)).SetInternal(err) } - if err := s.CreateAuthSignInActivity(c, user); err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) - } cookieExp := time.Now().Add(auth.CookieExpDuration) setTokenCookie(c, auth.AccessTokenCookieName, accessToken, cookieExp) userMessage := convertUserFromStore(user) @@ -396,50 +390,6 @@ func (s *APIV1Service) UpsertAccessTokenToStore(ctx context.Context, user *store return nil } -func (s *APIV1Service) CreateAuthSignInActivity(c echo.Context, user *store.User) error { - ctx := c.Request().Context() - payload := ActivityUserAuthSignInPayload{ - UserID: user.ID, - IP: echo.ExtractIPFromRealIPHeader()(c.Request()), - } - payloadBytes, err := json.Marshal(payload) - if err != nil { - return errors.Wrap(err, "failed to marshal activity payload") - } - activity, err := s.Store.CreateActivity(ctx, &store.Activity{ - CreatorID: user.ID, - Type: string(ActivityUserAuthSignIn), - Level: string(ActivityInfo), - Payload: string(payloadBytes), - }) - if err != nil || activity == nil { - return errors.Wrap(err, "failed to create activity") - } - return err -} - -func (s *APIV1Service) createAuthSignUpActivity(c echo.Context, user *store.User) error { - ctx := c.Request().Context() - payload := ActivityUserAuthSignUpPayload{ - Username: user.Username, - IP: echo.ExtractIPFromRealIPHeader()(c.Request()), - } - payloadBytes, err := json.Marshal(payload) - if err != nil { - return errors.Wrap(err, "failed to marshal activity payload") - } - activity, err := s.Store.CreateActivity(ctx, &store.Activity{ - CreatorID: user.ID, - Type: string(ActivityUserAuthSignUp), - Level: string(ActivityInfo), - Payload: string(payloadBytes), - }) - if err != nil || activity == nil { - return errors.Wrap(err, "failed to create activity") - } - return err -} - // removeAccessTokenAndCookies removes the jwt token from the cookies. func removeAccessTokenAndCookies(c echo.Context) { cookieExp := time.Now().Add(-1 * time.Hour) diff --git a/server/server.go b/server/server.go index 33b408b278131..e17cb99c5804b 100644 --- a/server/server.go +++ b/server/server.go @@ -126,9 +126,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store if err := s.apiV1Service.UpsertAccessTokenToStore(ctx, user, accessToken); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to upsert access token, err: %s", err)).SetInternal(err) } - if err := s.apiV1Service.CreateAuthSignInActivity(c, user); err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) - } cookieExp := time.Now().Add(auth.CookieExpDuration) // setTokenCookie sets the token to the cookie.