0
1

I have just done a fresh install of OSQA on a WebFaction account. However, I would like to implement a user registration system where the following happens:

  • the user enters their email into the registration form
  • OSQA checks to make sure the email matches a certain domain (e.g. @example.edu)
  • OSQA sends the user an email at that address
  • the user clicks a link in the email to set their password and activate their account

Is there a recommended or optimal way to do this so that it will not interfere with future versions of OSQA?

asked 12 May '11, 16:25

zgm's gravatar image

zgm
116133
accept rate: 16%

edited 12 May '11, 17:56

Andrew_S's gravatar image

Andrew_S ♦
5.6k45674

Hi zgm, and welcome. As this is a Q&A forum, we try to make sure that every question really is a question, not a statement or a fragment. So I've edited your question title, so that it's a meaningful question. Hopefully, this will help you get a speedy and useful answer to it.

(12 May '11, 17:57) Andrew_S ♦

Thanks Andrew_S, I'll be sure to follow the forum conventions in my future questions.

(12 May '11, 20:19) zgm

Ok, I found a solution. It's not optimal, but it's a start.

I modified the UserEmailField class in forum/forms/general.py like so:

class UserEmailField(forms.EmailField):
    def __init__(self,skip_clean=False,**kw):
        self.skip_clean = skip_clean
        super(UserEmailField,self).__init__(widget=forms.TextInput(attrs=dict(login_form_widget_attrs,
            maxlength=200)), label=mark_safe(_('your email address')),
            error_messages={'required':_('email address is required'),
                            'invalid':_('please enter a valid email address'),
                            'domain':_('please enter a valid @domain email address'),## add in new error case
                            'taken':_('this email is already used by someone else, please choose another'),
                            },
            **kw
            )
    def clean(self,email):
        """ validate if email exist in database
        from legacy register
        return: raise error if it exist """
        email = super(UserEmailField,self).clean(email.strip())
        ## My code begins
        if email.endswith('@domain.edu'): #checks if email matches the specified domain
            return email
         else:
            raise forms.ValidationError(self.error_messages['domain'])
        ## My code ends

The remaining email verification works the way it normally does in OSQA. I think ideally you would want this stored in some kind of setting. Perhaps someone who is more familiar with Django and the OSQA source could shed some light on this.

link

answered 25 May '11, 18:59

zgm's gravatar image

zgm
116133
accept rate: 16%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×101
×75
×17
×2

Asked: 12 May '11, 16:25

Seen: 611 times

Last updated: 25 May '11, 18:59

powered by OSQA