예제 #1
0
def main():
    # Generate one
    secret = Secret()
    secret.generate()

    # Run app
    app = configure()
    server = HTTPServer(app, xheaders=True)
    server.listen(port=options.port)

    logging.info(secret.read())
    logging.info('Running on port %s' % options.port)
    IOLoop.current().start()
예제 #2
0
파일: api.py 프로젝트: brianherbert/riverid
    def requestpassword(self, email):
        Validator.email(email)

        token = Secret.generate(16)

        if self.user.exists(email):
            subject = 'RiverID: Please confirm your password change.'
            self.user.update(email, token=token)
        else:
            subject = 'RiverID: Please confirm your email address.'
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(MAIL_FROM, email, subject, token)
예제 #3
0
파일: api.py 프로젝트: d8agroup/riverid
    def requestpassword(self, email, mailbody):
        Validator.email(email)

        token = Secret.generate(16)

        if self.user.exists(email):
            subject = _('RiverID: Please confirm your password change.')
            self.user.update(email, token=token)
        else:
            subject = _('RiverID: Please confirm your email address.')
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(MAIL_FROM, email, subject, mailbody, token=token)
예제 #4
0
    def requestpassword(self, email, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(email)

        token = Secret.generate(16)

        if mailfrom is None:
            mailfrom = MAIL_FROM

        if self.user.exists(email):
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your password change.')
            self.user.update(email, token=token)
        else:
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your email address.')
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(mailfrom, email, mailsubject, mailbody, token=token)
예제 #5
0
파일: api.py 프로젝트: d8agroup/riverid
    def register(self, email, password):
        Validator.email(email)
        Validator.password(password)

        if self.user.exists(email):
            raise RiverException(_('The given email address has already been registered.'))
        
        user_id = Secret.generate(128)

        self.user.insert(email, enabled=True, id=user_id, password=Secret.hash(password, SALT))

        return user_id
예제 #6
0
파일: api.py 프로젝트: brianherbert/riverid
    def changeemail(self, oldemail, newemail, password):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException('The password is incorrect for this user.')
        
        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(MAIL_FROM, newemail, 'RiverID Email Change', token)
예제 #7
0
파일: api.py 프로젝트: d8agroup/riverid
    def register(self, email, password):
        Validator.email(email)
        Validator.password(password)

        if self.user.exists(email):
            raise RiverException(
                _('The given email address has already been registered.'))

        user_id = Secret.generate(128)

        self.user.insert(email,
                         enabled=True,
                         id=user_id,
                         password=Secret.hash(password, SALT))

        return user_id
예제 #8
0
파일: api.py 프로젝트: d8agroup/riverid
    def changeemail(self, oldemail, newemail, password, mailbody):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(MAIL_FROM,
                  newemail,
                  _('RiverID Email Change'),
                  mailbody,
                  token=token)
예제 #9
0
파일: api.py 프로젝트: d8agroup/riverid
    def signin(self, email, password):
        Validator.email(email)
        Validator.password(password)

        user = self.user.get(email)

        if user['enabled'] == False:
            raise RiverException(_('The account is disabled.'))

        if user['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        session_id = Secret.generate(64)
        session_start = datetime.utcnow().isoformat()

        self.user.add(email, 'session', id=session_id, start=session_start)

        return dict(user_id=user['id'], session_id=session_id)
예제 #10
0
파일: api.py 프로젝트: brianherbert/riverid
    def signin(self, email, password):
        Validator.email(email)
        Validator.password(password)

        user = self.user.get(email)

        if user['enabled'] == False:
            raise RiverException('The account is disabled.')
        
        if user['password'] != Secret.hash(password, SALT):
            raise RiverException('The password is incorrect for this user.')

        session_id = Secret.generate(64)
        session_start = datetime.utcnow().isoformat()

        self.user.add(email, 'session', id=session_id, start=session_start)

        return dict(user_id=user['id'], session_id=session_id)
예제 #11
0
    def changeemail(self, oldemail, newemail, password, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        if self.user.exists(newemail):
            raise RiverException(_('The new email address has already been registered.'))

        if mailsubject is None:
            mailsubject = _('CrowdmapID Email Change')

        if mailfrom is None:
            mailfrom = MAIL_FROM

        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(mailfrom, newemail, mailsubject, mailbody, token=token)