Beispiel #1
0
def profile(request):
    if request.POST:
        user = User.objects.get(id=request.user.id)

        user_profile, created = UserProfile.objects.get_or_create(user=request.user)
        if request.POST.get('payment_paypal', '') == "checked":
            user_profile.payment_service = "paypal"
        else:
            user_profile.payment_service = "wepay"
        user_profile.payment_service_email = request.POST.get('payment_service_email', '')
        save = False
        try:
            if user.username != request.POST.get('username', ''):
                user.username = request.POST.get('username', '')
                save = True
            if user.email != request.POST.get('email', ''):
                user.email = request.POST.get('email', '')
                save = True
            if request.POST.get('password', ''):
                algo = 'sha1'
                salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
                hsh = get_hexdigest(algo, salt, request.POST.get('password', ''))
                user.password = '******' % (algo, salt, hsh)
                save = True
            if save:
                user.save()

        except Exception, e:
            return HttpResponse("{error}".format(error=e))

        user_profile.save()

        return HttpResponse("Your profile has been saved")
Beispiel #2
0
 def set_password(self, raw_password):
     """Sets the user's password - always use this rather than directly
     assigning to :attr:`~mongoengine.django.auth.User.password` as the
     password is hashed before storage.
     """
     algo = 'sha1'
     salt = get_hexdigest(algo, str(random()), str(random()))[:5]
     hash = get_hexdigest(algo, salt, raw_password)
     self.password = '******' % (algo, salt, hash)
     self.save()
     return self
Beispiel #3
0
 def set_password(self, raw_password):
     """Sets the user's password - always use this rather than directly
     assigning to :attr:`~mongoengine.django.auth.User.password` as the
     password is hashed before storage.
     """
     algo = 'sha1'
     salt = get_hexdigest(algo, str(random()), str(random()))[:5]
     hash = get_hexdigest(algo, salt, raw_password)
     self.password = '******' % (algo, salt, hash)
     self.save()
     return self
Beispiel #4
0
def check_password(raw_password, enc_password):
    """
    Returns a boolean of whether the raw_password was correct. Handles
    encryption formats behind the scenes.
    """
    algo, salt, hsh = enc_password.split('$')
    return hsh == utils.get_hexdigest(algo, salt, raw_password)
Beispiel #5
0
 def check_password(self, raw_password):
     """Checks the user's password against a provided password - always use
     this rather than directly comparing to
     :attr:`~mongoengine.django.auth.User.password` as the password is
     hashed before storage.
     """
     algo, salt, hash = self.password.split('$')
     return hash == get_hexdigest(algo, salt, raw_password)
Beispiel #6
0
 def check_password(self, raw_password):
     """Checks the user's password against a provided password - always use
     this rather than directly comparing to
     :attr:`~mongoengine.django.auth.User.password` as the password is
     hashed before storage.
     """
     algo, salt, hash = self.password.split('$')
     return hash == get_hexdigest(algo, salt, raw_password)
Beispiel #7
0
 def check_password(self, raw_password):
     """
     Returns a boolean of whether the raw_password was correct. Handles
     encryption formats behind the scenes.
     """
     # Backwards-compatibility check. Older passwords won't include the
     # algorithm or salt.
     if '$' not in self.password:
         is_correct = (self.password == utils.get_hexdigest('md5', '', raw_password))
         if is_correct:
             # Convert the password to the new, more secure format.
             self.set_password(raw_password)
             self.put()
         return is_correct
     return check_password(raw_password, self.password)
Beispiel #8
0
def create_db(system_password):
    "Create the database and load the designs and the 'system' account."
    site = configuration.site
    server = couchdb.Server(site.COUCHDB_SERVER)
    db = server.create(site.COUCHDB_DATABASE)
    utils.load_designs(db)
    doc = utils.load_document(db,
                              'account',
                              identifier='system',
                              role='admin',
                              password=utils.get_hexdigest(system_password),
                              fullname='System',
                              initials='SYS')
    utils.load_document(db,
                        'log',
                        docid=doc['_id'],
                        action='created',
                        account='system')
    utils.load_document(db,
                        'system',
                        identifier='settings',
                        project_steps=[
                            "contract",
                            "QC incoming samples",
                            "queued",
                            "library prep",
                            "qPCR",
                            "SOLiD WFA",
                            "454 titration",
                            "amplification",
                            "sequencing",
                            "data transfer",
                            "data analysis",
                            "data delivery",
                            "invoice",
                            "payment"
                            ],
                        project_references=[
                            "hg19",
                            "other",
                            "unknown"
                            ],
                        project_platforms=[
                            "Illumina Hiseq",
                            "SOLiD",
                            "GS-FLX"
                            ],
                        project_applications=[
                            "total RNA",
                            "small RNA",
                            "MP de novo",
                            "MP metagenomics",
                            "custom sequence capture",
                            "metagenomics",
                            "exome sequencing",
                            "de novo",
                            "WGS",
                            "ChipSeq",
                            "epigenomics",
                            "finished library"
                            ],
                        project_lab_protocols=[
                            "DNA standard",
                            "total RNA",
                            "small RNA",
                            "mate pair",
                            "sequence capture"
                            ],
                        project_sequencing_setups=[
                            "Illumina PE 2*100",
                            "Illumina PE 2*50",
                            "Illumina SR 1*100",
                            "Illumina SR 1*50",
                            "SOLiD 2*75",
                            "SOLiD 1*50",
                            "SOLiD 1*35",
                            "SOLiD 75+35",
                            "SOLiD 50+35",
                            "454 400",
                            "454 850"
                            ],
                        sample_steps=[
                            "arrival",
                            "QC incoming",
                            "library prep",
                            "QC library prep",
                            "qPCR",
                            "sequencing",
                            "QC sequencing"
                            ],
                        sample_types=[
                            "DNA",
                            "cDNA",
                            "total RNA",
                            "mRNA",
                            "small RNA",
                            "metagenomics",
                            "ChipSeq",
                            "epigenetics",
                            "library prep",
                            "captured library",
                            "other"
                            ],
                        workset_steps=[
                            "designed",
                            "sequencing",
                            "clustering"
                            ],
                        workset_types=[
                            "collection",
                            "plate",
                            "lane",
                            "flowcell"
                            ]
                        )