diff --git a/.github/workflows/release-version-update.yml b/.github/workflows/release-version-update.yml index c62158d1f..8105bc885 100644 --- a/.github/workflows/release-version-update.yml +++ b/.github/workflows/release-version-update.yml @@ -14,9 +14,15 @@ jobs: - name: Get release information id: get_release - uses: dawidd6/action-get-latest-release@v3 - with: - release: true + run: | + response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest) + echo "$response" | jq '.tag_name, .name, .published_at, .body, .html_url' | tee /tmp/release_info + echo "::set-output name=tag_name::$(echo "$response" | jq -r .tag_name)" + echo "::set-output name=name::$(echo "$response" | jq -r .name)" + echo "::set-output name=published_at::$(echo "$response" | jq -r .published_at)" + echo "::set-output name=body::$(echo "$response" | jq -r .body)" + echo "::set-output name=html_url::$(echo "$response" | jq -r .html_url)" + - name: Update version.json run: | @@ -25,7 +31,7 @@ jobs: "release_name": "${{ steps.get_release.outputs.name }}", "published_at": "${{ steps.get_release.outputs.published_at }}", "body": "${{ steps.get_release.outputs.body }}" - "release_url": "${{ steps.get_release.outputs.html_url }}" + "html_url": "${{ steps.get_release.outputs.html_url }}" }' > version.json - name: Create new branch @@ -41,10 +47,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: update-version-${{ steps.get_release.outputs.tag_name }} - title: "Update version.json for release ${{ steps.get_release.outputs.tag_name }}" - body: "This PR updates version.json with the latest release information." - base: develop # Target branch for the pull request + run: | + curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/pulls \ + -d '{ + "title": "Update version.json for release ${{ steps.get_release.outputs.tag_name }}", + "body": "This PR updates version.json with the latest release information.", + "head": "update-version-${{ steps.get_release.outputs.tag_name }}", + "base": "develop" + }' diff --git a/src/apps/profiles/forms.py b/src/apps/profiles/forms.py index 7b4ad71e8..3adb4d8e3 100644 --- a/src/apps/profiles/forms.py +++ b/src/apps/profiles/forms.py @@ -33,3 +33,7 @@ class LoginForm(forms.Form): username = forms.CharField(max_length=150) password = forms.CharField(max_length=150, widget=forms.PasswordInput) + + +class ActivationForm(forms.Form): + email = forms.EmailField(max_length=254, required=True) diff --git a/src/apps/profiles/urls_accounts.py b/src/apps/profiles/urls_accounts.py index 779292962..69f3f54ad 100644 --- a/src/apps/profiles/urls_accounts.py +++ b/src/apps/profiles/urls_accounts.py @@ -7,6 +7,7 @@ urlpatterns = [ url(r'^signup', views.sign_up, name="signup"), + path('resend_activation/', views.resend_activation, name='resend_activation'), path('login/', views.log_in, name='login'), path('logout/', views.LogoutView.as_view(), name='logout'), path('password_reset/', views.CustomPasswordResetView.as_view(), name='password_reset'), diff --git a/src/apps/profiles/views.py b/src/apps/profiles/views.py index a6a21cb64..08c697e85 100644 --- a/src/apps/profiles/views.py +++ b/src/apps/profiles/views.py @@ -19,7 +19,7 @@ from api.serializers.profiles import UserSerializer, OrganizationDetailSerializer, OrganizationEditSerializer, \ UserNotificationSerializer -from .forms import SignUpForm, LoginForm +from .forms import SignUpForm, LoginForm, ActivationForm from .models import User, Organization, Membership from oidc_configurations.models import Auth_Organization from .tokens import account_activation_token @@ -82,8 +82,8 @@ def activate(request, uidb64, token): messages.success(request, f'Your account is fully setup! Please login.') return redirect('accounts:login') else: - messages.error(request, f"Activation link is invalid. Please double check your link.") - return redirect('accounts:signup') + messages.error(request, f"Activation link is invalid or expired. Please double check your link.") + return redirect('accounts:resend_activation') return redirect('pages:home') @@ -135,6 +135,31 @@ def sign_up(request): return render(request, 'registration/signup.html', context) +def resend_activation(request): + context = {} + if request.method == 'POST': + form = ActivationForm(request.POST) + if form.is_valid(): + + email = form.cleaned_data.get('email') + user = User.objects.filter(email=email).first() + + if user and not user.is_active: + activateEmail(request, user, email) + return redirect('pages:home') + else: + if not user: + messages.error(request, "No account found with this email.") + elif user.is_active: + messages.error(request, "This account is already active.") + else: + context['form'] = form + + if not context.get('form'): + context['form'] = ActivationForm() + return render(request, 'registration/resend_activation.html', context) + + def log_in(request): # Fectch next redirect page after login @@ -173,7 +198,7 @@ def log_in(request): else: return redirect(next) else: - messages.error(request, "Account is not active. Activate your account using the link sent to you by email.") + context['activation_error'] = "Your account is not activated. Please check your email for the activation link" else: messages.error(request, "Wrong Credentials!") else: diff --git a/src/templates/base.html b/src/templates/base.html index 8b0271172..337eba159 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -229,7 +229,7 @@

CodaBench

{% if VERSION_INFO.tag_name != 'invalid' and VERSION_INFO.tag_name != 'unknown' %}
- {{ VERSION_INFO.tag_name }} + {{ VERSION_INFO.tag_name }}
{% endif %} diff --git a/src/templates/registration/login.html b/src/templates/registration/login.html index b2c29a8d1..efdc519df 100644 --- a/src/templates/registration/login.html +++ b/src/templates/registration/login.html @@ -7,6 +7,11 @@

Login

+ {% if activation_error %} +
+ {{ activation_error }} or click here to send the activation email again +
+ {% endif %}
{% csrf_token %} diff --git a/src/templates/registration/resend_activation.html b/src/templates/registration/resend_activation.html new file mode 100644 index 000000000..9b17edb1c --- /dev/null +++ b/src/templates/registration/resend_activation.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} +{% load static %} + +{% block content %} +
+

+ Resend Activation +

+
+
Activation link expired?
+

Enter your email in the form below and we'll send you a new activation link for your account.

+
+ + {% csrf_token %} + +
+
+ + +
+
+ + +
+ +
+{% endblock %} \ No newline at end of file diff --git a/src/utils/data.py b/src/utils/data.py index 7d743f361..d7b7669c7 100644 --- a/src/utils/data.py +++ b/src/utils/data.py @@ -43,7 +43,7 @@ def __call__(self, instance, filename): return path -def make_url_sassy(path, permission='r', duration=60 * 60 * 24, content_type='application/zip'): +def make_url_sassy(path, permission='r', duration=60 * 60 * 24 * 5, content_type='application/zip'): assert permission in ('r', 'w'), "SASSY urls only support read and write ('r' or 'w' permission)" client_method = None # defined based on storage backend diff --git a/version.json b/version.json index 6d0c65f69..7bc02172f 100644 --- a/version.json +++ b/version.json @@ -3,5 +3,5 @@ "release_name": "Release 1.11.0", "published_at": "2024-09-16", "body": "", - "release_url": "https://github.com/codalab/codabench/releases/tag/v1.11.0" + "html_url": "https://github.com/codalab/codabench/releases/tag/v1.11.0" } \ No newline at end of file