- token = UserToken.find_by(:token => params[:confirm_string])
- if token&.user&.active?
- flash[:error] = t("confirmations.confirm.already active")
- redirect_to login_path
- elsif !token || token.expired?
- flash[:error] = t("confirmations.confirm.unknown token")
+ token = params[:confirm_string]
+
+ user = User.find_by_token_for(:new_user, token) ||
+ UserToken.unexpired.find_by(:token => token)&.user
+
+ if !user
+ flash[:error] = t(".unknown token")