def register():
    title = ddb + "register"
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        phone = form.phone.data
        address = form.address.data
        city = form.city.data
        zipcode = form.zipcode.data
        # admin = form.admin.data
        # print(username, email, password)

        # create new instance of User
        new_user = User(username, email, password,phone, address, city, zipcode)
        # add new instance to our database
        db.session.add(new_user)
        # commit database
        db.session.commit()

        # send email to new user
        msg = Message(f"Welcome, {username}", [email])
        msg.body = 'Thank you for signing up for the most glorious death of your bugs. I hope you enjoy your new carnage!'
        msg.html = "<p>Thanks you so much for signing up for the Dale's Dead Bugs service. Where we do buggin right! We may, or may not, be in Liberia!</p>"

        mail.send(msg) 

        flash("It may be a crack in your internet, or the Chinese are making their move!", "success")
        return redirect(url_for('index'))
    return render_template('register.html', title=title, form=form)
Exemple #2
0
def email_log(message):
    msg = Message("%s Notice Fitboard" % (message), recipients=["*****@*****.**"])
    msg.body = "NOTICE %s \n Logile Attached \n" % (message)
    with app.open_resource("fitboard.log") as fp:
        msg.attach("fitboard.log", "text/plain", fp.read())
    mail.send(msg)
    return
Exemple #3
0
def register():
    form = UserInfoForm()
    context = {'form': form}
    if request.method == 'POST' and form.validate():

        # Get Information
        username = form.username.data
        email = form.email.data
        password = form.password.data

        print(username, email, password)

        # Create new instance of User
        new_user = User(username, email, password)

        # Add user to db
        db.session.add(new_user)
        db.session.commit()

        # flash success message
        flash("You have successfully registered", 'success')

        # Flask Email Sender
        msg = Message(f'Thanks for signing up, {username}!',
                      recipients=[email])
        msg.body = ('Congrats on signing up! I hope you enjoy our site!!')
        msg.html = ('<h1>Welcome to Our Site</h1>'
                    '<p>This will be super cool!</p>')

        mail.send(msg)

        return redirect(url_for('index'))
    return render_template('register.html', **context)
Exemple #4
0
def userregister():
    if request.method == 'POST':
        session = DBSession()
        email = request.form['useremail']
        username = request.form['username']
        password = request.form['userpassword']
        password = generate_password_hash(password)
        print(email)
        if session.query(User).filter(User.email == email).first():
            return render_template('register.html', msg='该邮箱已被注册!')
        else:
            adduser = User(password=password, username=username, email=email, admin=0,activated=0)
            session.add(adduser)
            session.commit()
            os.makedirs(os.path.join(os.getcwd(),'static','files','{0}'.format(adduser.userid)))
            url='http://47.94.138.25/activate/{0}'.format(gen_token(adduser.userid))
            # message=Message('Account authorize',sender='*****@*****.**',recipients=['{}'.format(username),'{}'.format(email)])
            message = Message('Account authorize', sender='*****@*****.**',recipients=['*****@*****.**'])
            message.body="Hello,{0}<br>This email is from admin!<br>Your account has not been activated yet!<br><a href='{1}'>click here to activate your account!</a><br>if you mistaken the email,please ignore it!".format(username,url)
            mail.send(message)
            session.close()

            return redirect(url_for('users.userlogin'))
    else:
        return render_template('register.html')
def register():
    title = 'Kekambas Blog | REGISTER'
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username= form.username.data
        email= form.email.data
        password= form.password.data
        # print(username, email, password)
        # create a new instance of User
        new_user= User(username, email, password)
        # add new instance of our database
        db.session.add(new_user)
        # commit database
        db.session.commit()
        # Send email to new user
        msg= Message(f'Welcome, {username}', [email])
        msg.body = 'Thank you for signing up for the Kekembas blog. I hope you enjoy our app!'
        msg.html = '<p> Thank you so much for signing up for the Kekemnbas blog. I hope you enjoy our app </p>'
        # send email

        mail.send(msg)

        flash('Welcome aboard!', 'success')
        return redirect(url_for("hello_world"))
    return render_template('register.html', title = title, form=form)
Exemple #6
0
def register():
    title = 'Kekembas blog | REGISTER'
    form = UserInfoForm()
    

    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data

        print(username,email, password)
        
        #create a new instance of User
        new_user = User(username,email,password)
        #add new instance of use
        db.session.add(new_user)
        #commit database
        db.session.commit()

        #SEND EMAIL TO NEW USER
        msg = Message(f"welcome, {username}", [email])
        msg.body = 'Thank you for siging up for the kekembas blog. I hope you enjoy our blog!'
        msg.html = '<p>Thank you so much for signing up for out blog!</p>'
        
        mail.send(msg)

        flash("You have succesfully signed up!", "success")
        return redirect(url_for('index'))

    return render_template('register.html', title=title,form=form)
Exemple #7
0
def RegisterPhoneNum():
    title = 'Register Phone Number'
    regPhone = RegisterPhoneForm()
    if request.method == 'POST' and regPhone.validate:
        username = regPhone.username.data
        firstName = regPhone.firstName.data
        lastName = regPhone.lastName.data
        phoneNum = regPhone.phoneNum.data
        email = regPhone.email.data
        address = regPhone.address.data
        city = regPhone.city.data
        state = regPhone.state.data
        password = regPhone.password.data

        print(username, firstName)

        new_user = User(username, firstName, lastName, phoneNum, email,
                        address, city, state, password)
        db.session.add(new_user)
        db.session.commit()

        msg = Message(f"Welcome, {username}", [email])
        msg.html = "<p>You have now signed up for a useless phonebook! Enjoy the junk mail we will be sending you!!!!</p>"
        mail.send(msg)

        flash("You have successfully signed up!", "success")
        return redirect(url_for('index'))

    return render_template('registerPhone.html',
                           title=title,
                           regPhone=regPhone)
def register():
    title = "Virtual Tour Mates | REGISTER"
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        # print(username, email, password)
        
        # create a new instance of User
        new_user = User(username, email, password)
        # add new instance to our database
        db.session.add(new_user)
        # commit database
        db.session.commit()

        # Send email to new user
        msg = Message(f'Welcome, {username}', [email])
        msg.body = "Thank you for signing up for the Virtual Tour Mates. I hope you enjoy our app!"
        msg.html = "<p>Thank you so much for signing up for the Virtual Tour Mates. I hope you enjoy our app!</p>"

        mail.send(msg)

        flash("You have succesfully signed up!", "success")
        return redirect(url_for('index'))
    return render_template('register.html', title=title, form=form)
Exemple #9
0
def register():
    title = 'Kekembas Blog | REGISTER'
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        username = form.username.data
        email = form.email.data
        password = form.password.data
        print(username, email, password)

        #create a new instance of user
        new_user = User(username, email, password)
        #add new instance to database
        db.session.add(new_user)
        #commit database
        db.session.commit()

        #send email to new user
        msg = Message(f'Welcome, {username}', [email])
        msg.body = 'Thank you for signing up to the Kekembas Blog, I hope you enjoy our app!'
        msg.html = '<p> Thank you so much for signing up for the Kekembas blog . I hopt you enjoy our app!</p>'

        mail.send(msg)

        flash("You have succesfully sign up!", "success")
        return redirect(url_for('hello_world'))

    return render_template('register.html', title=title, form=form)
Exemple #10
0
def register():
    form = RegistrationForm()

    if request.method == 'POST':
        if form.validate() is False:
            flash("All fields are required for registration.")
            return render_template('register.html', form=form)
        else:
            newuser = User(form.username.data,
                           form.email.data, form.passwd.data)
            db.session.add(newuser)
            db.session.commit()

            # obtuser = User.query.filter_by(email=form.email.data.lower()).first()
            email = newuser.email.encode('ascii', 'ignore')
            reg_key = newuser.reg_key.encode('ascii', 'ignore')
            subject = "Your confirmation email from microBLOG"
            mail_to_be_sent = Message(subject=subject, recipients=[newuser.email])
            conf_url = url_for('confirm', reg_key=reg_key, _external=True)
            mail_to_be_sent.body = "Please click the link to confirm registration at microBLOG: %s" % conf_url
            mail.send(mail_to_be_sent)
            flash('Please check your email to confirm registration.  Then you can start using the site.')
            # session['email'] = newuser.email
            return redirect(url_for('homepage'))

    elif request.method == 'GET':
        return render_template('register.html', form=form)
Exemple #11
0
def reg_user():
    form = RegForm()
    name = None
    email = None
    password = None

    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        password = form.password.data
        email_con = email
        email_exists = Users.query.filter_by(user_email=email).first()
        if email_exists:
            flash(u'Email already exist, please login into your account',
                  'error')
            return redirect(url_for('auth.reg_user'))

        else:
            # the function below creates new user records in database
            Users.create_user(name, email, password)
            flash(
                'Registration Successful, an email confirmation link has been sent to your email',
                category='success')

            # this part send emil verfication link
            token = s.dumps(email_con, salt='email_verify')
            msg = Message('Confirm Email',
                          sender='*****@*****.**',
                          recipients=[email_con])
            link = url_for('auth.verify_email', token=token, _external=True)
            msg.body = 'Your link is {}'.format(link)
            mail.send(msg)
            return redirect(url_for('auth.home'))

    return render_template('reg.html', form=form)
Exemple #12
0
def student_registration():

    if request.method == "POST":

        first_name = request.form['first_name']
        last_name = request.form['last_name']
        student_id = random.randrange(100000, 999999)
        student_email = request.form['student_email']
        parent_email = request.form['parent_email']
        student_phone_number = request.form['student_phone_number']
        parent_phone_number = request.form['parent_phone_number']
        city = request.form['city']
        standard = request.form['standard']
        current_address = request.form['current_address']
        board = request.form['board']

        subj = request.form.getlist('sub')
        #print(subj)

        subjects = ','.join(subj)

        auto_password = random.randrange(100000, 999999)

        string_pass = str(auto_password)

        hashed_password = bcrypt.generate_password_hash(string_pass).decode(
            'utf-8')

        student_password = hashed_password

        user = Students_data(student_id, first_name, last_name, student_email,
                             parent_email, student_phone_number,
                             parent_phone_number, city, standard,
                             current_address, board, subjects,
                             student_password)
        db.session.add(user)
        db.session.commit()

        ### Confirmation mail code  ###
        '''
        token = t.dumps(student_email, salt='email-confirm')
        msg = Message('Confirmation email', sender='*****@*****.**', recipients=[student_email])
        link = url_for('confirm_email', token=token, _external=True )
        msg.body = 'Your link is {}'.format(link)
        mail.send(msg)
        '''

        msg = Message(subject='Login details...',
                      recipients=[student_email, parent_email])
        msg.body = "Hello {} {}, Your login details are >> Student ID = {}, Password = {}".format(
            first_name, last_name, student_id, auto_password)
        mail.send(msg)

        msg = flash(
            'Registration successful ! Login details are on your mail.',
            'success')
        return render_template('student_login.html', msg=msg, subj=subj)

    return render_template('student_registration.html')
Exemple #13
0
 def __init__(self, email):
     try:
         msg = Message(f"Регистрация на сайте  {adpess_site}",
                       recipients=[f'{email}'])
         msg.html = f"<h2>Подтреждение о регистрации на сайте</h2>"
         mail.send(msg)
     except:
         pass
Exemple #14
0
def send_async_email(recipients, link):
    """Background task to send an email with Flask-Mail."""
    subject = "Confirmation email for trololo.info"
    sender = '*****@*****.**'
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = 'You can activate your account here: %s' % link
    with app.app_context():
        mail.send(msg)
 def send_mail_with_order_details(details):
     msg = Message(
         'From Books Store',
         sender=mail_user,
         recipients=[details[0]]
     )
     msg.html = render_template('email.html', details=details)
     mail.send(msg)
Exemple #16
0
def email_log(message):
    msg = Message("%s Notice Fitboard" % (message),
                  recipients=["*****@*****.**"])
    msg.body = "NOTICE %s \n Logile Attached \n" % (message)
    with app.open_resource("fitboard.log") as fp:
        msg.attach("fitboard.log", "text/plain", fp.read())
    mail.send(msg)
    return
Exemple #17
0
def message():
    formName = request.form['name']
    formEmail = request.form['email']
    formMessage = request.form['message']
    msg = Message('Hello, this is ' + formName + ' from ' + formEmail, sender=formEmail, recipients=['*****@*****.**'])
    msg.body = formMessage
    mail.send(msg)
    return 'success'
Exemple #18
0
def send_email(eml):
    """发送邮件"""
    message = Message('修改密码', recipients=[eml])
    code = ''.join(sample(ascii_letters + digits, 6))
    message.body = '【51商城】验证码:{}\t{}\n{}'.format(code, '此次验证码有效期为5分钟',
                                                 '如果非本人操作,请忽略!')
    mail.send(message)
    # TODO 应该存入redis 然后设置过期时间为3分钟
    session['code'] = code
Exemple #19
0
def message(email,message):
    data = request.get_json()
    api_key = data.get("api_key")
    times = data.get("time_stamp")
    new_user = User.api_authenticate(api_key)
    new_request = Message(None,data['email'],new_user.email,data['message'],new_user.image_path,new_user.First_name,new_user.Last_name,times)
    new_request.save()
    if new_request:
        return jsonify({"token":times})
    return jsonify({"message":"failed"})
Exemple #20
0
 def __init__(self, form):
     try:
         msg = Message("Пароль от аккаунта", recipients=[f'{form.address.data}'])
         msg.html = f"<h2>Для изменения пароля на сайте {adpess_site}\n" \
                    f"передите по ссылке и введите новый пароль \n" \
                    f"<a href='{adpess_site}/update_password/{form.address.data}'>Изменить пароль" \
                    f"</a></h2>\n<p></p>"
         mail.send(msg)
     except :
         pass
Exemple #21
0
 def setUp(self):
     db.create_all()
     user1 = User("Steph", "Curry")
     user2 = User("Klay", "Thompson")
     user3 = User("Draymond", "Green")
     message1 = Message("Splash!", 1)
     message2 = Message("My dog's name is Rocco", 2)
     message3 = Message("Dre day all day", 3)
     db.session.add_all([user1, user2, user3])
     db.session.add_all([message1, message2, message3])
     db.session.commit()
Exemple #22
0
 def setUp(self):
     db.create_all()
     user1 = User("Elie", "Schoppik")
     user2 = User("Tim", "Garcia")
     user3 = User("Matt", "Lane")
     db.session.add_all([user1, user2, user3])
     message1 = Message("Hello Elie!!", 1)
     message2 = Message("Goodbye Elie!!", 1)
     message3 = Message("Hello Tim!!", 2)
     message4 = Message("Goodbye Tim!!", 2)
     db.session.add_all([message1, message2, message3, message4])
     db.session.commit()
Exemple #23
0
 def setUp(self):
     db.create_all()
     user1 = User("Elie", "Schoppik", "image")
     user2 = User("Tim", "Garcia", "image")
     user3 = User("Matt", "Lane", "image")
     db.session.add_all([user1, user2, user3])
     message1 = Message("Hello Elie!!", 1)
     message2 = Message("Goodbye Elie!!", 1)
     message3 = Message("Hello Tim!!", 2)
     message4 = Message("Goodbye Tim!!", 2)
     db.session.add_all([message1, message2, message3, message4])
     email1 = Email("*****@*****.**", 1)
     email2 = Email("*****@*****.**", 2)
     db.session.add_all([email1, email2])
     db.session.commit()
    def setUp(self):
        app.config[
            "SQLALCHEMY_DATABASE_URI"] = 'postgres://localhost/warbler_test_db'
        db.create_all()

        user1 = User(username="******",
                     email="*****@*****.**",
                     password="******")
        user2 = User(username="******",
                     email="*****@*****.**",
                     password="******")
        msg1 = Message(text="rithmrithm I was here", user_id=user1.id)
        msg2 = Message(text="Its a good good day", user_id=user2.id)
        db.session.add_all([msg1, msg2, user1, user2])
        db.session.commit()
def add_message(body):
    subject = body['subject']
    sender = body['sender']
    receiver_name = body['receiver']
    message = body['message']

    if subject is None:
        raise ValidationError("Subject is missing", 401)

    if sender is None:
        raise ValidationError("Sender is missing", 401)

    if receiver_name is None:
        raise ValidationError("Receiver is missing", 401)

    if message is None:
        raise ValidationError("Message is missing", 401)

    current_user = User.query.filter(User.email == sender).first()

    if current_user is None:
        raise ValidationError("Invalid sender", 401)

    new_message = Message(sender=sender,
                          receiver=receiver_name,
                          subject=subject,
                          message=message)

    db.session.add(new_message)
    db.session.commit()
    db.session.flush()

    return {'status': True}
Exemple #26
0
    def prepare_email(self, attachment) -> Message:
        with self.app_obj.open_resource('forms/{}'.format(f_name)) as file:
            attachment = Attachment(
                filename=f_name,
                data=attachment,
                content_type='application/vnd.ms-excel'
            )

        msg = Message(
            subject='Wordified file',
            sender=app.config['ADMINS'][0],
            recipients=[recipient],
            attachments=[attachment],
            body=(
                """
                Dear user,

                Please find attached your file. It contains two sheets:
                one with the positive indicators for each label and one
                with the negative indicators (note that if you have only
                two labels, the positive indicators of one label are the
                negative ones of the other, and vice versa). If you do not
                see any indicators, you might have provided too few texts
                per label.
                
                Your MilaNLP Team
                """
            ),
        )

        return msg
Exemple #27
0
def get_messages(api_key):
        token = User.api_authenticate(api_key)
        if token:
            view_friends = Message.get_messages(token.email)
            print(view_friends)
            return jsonify({"friends":view_friends,"token":token.Api_key})
        return jsonify({"message":"failed"})
Exemple #28
0
def contact():
    form = ContactForm()
    if request.method == 'GET':
        return render_template('contact.html', form=form)
    else:
        if form.validate() == False:
            # errors are automatically stored in the form and template has access to them
            flash_errors(form)
            return render_template('contact.html', form=form)
        else:
            msg = Message("message from petri",
                          sender=form.email.data,
                          recipients=['*****@*****.**', '*****@*****.**'])
            msg.body = """From: %s %s <%s> %s""" % (form.firstname.data, form.lastname.data, form.email.data, form.message.data)
            mail.send(msg)
            flash('Your message been successfully sent')
            return render_template('contact.html', form=form)
Exemple #29
0
def register():
    form = SignupForm()
    if request.method == 'POST':
        if form.validate() == False:
            return render_template('register.html', form=form)
        else:
            password = form.password.data
            email = form.email.data
            newuser = User(email, password)
            msg = Message('hie', sender='*****@*****.**', recipients=['*****@*****.**'])
            msg.body = """ From: %s  """ % (form.email.data)
            mail.send(msg)
            db.session.add(newuser)
            db.session.commit()
            if current_user:
                return redirect(url_for('dashboard'))
    elif request.method == 'GET':
        return render_template('register.html', form=form)
Exemple #30
0
 def setUp(self):
     """ set up, create 2 users and commit to test db """
     app.config[
         "SQLALCHEMY_DATABASE_URI"] = 'postgres://localhost/warbler_test_db'
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     db.create_all()
     password1 = bcrypt.generate_password_hash("password").decode('UTF-8')
     password2 = bcrypt.generate_password_hash("rithmrithm").decode('UTF-8')
     user1 = User(username="******",
                  email="*****@*****.**",
                  password=password1)
     user2 = User(username="******",
                  email="*****@*****.**",
                  password=password2)
     msg1 = Message(text="rithmrithm I was here", user_id=user1.id)
     msg2 = Message(text="Its a good good day", user_id=user2.id)
     db.session.add_all([msg1, msg2, user1, user2])
     db.session.commit()
Exemple #31
0
def signup():
    title = "Sign Up"
    form = CustomerInfo()
    if request.method == "POST" and form.validate():
        first_name = form.first_name.data
        last_name = form.last_name.data
        username = form.username.data
        phone = form.phone.data
        email = form.email.data
        password = form.password.data
        new_user = User(first_name, last_name, username, phone, email, password)
        db.session.add(new_user)
        db.session.commit()
        msg = Message(f'Hello, {username} - welcome to E-Commerce Site', [email])
        msg.body = 'Welcome to E-Commerce Site! Happy to have you.'
        mail.send(msg)
        flash("You're signed up!", 'success')
        return redirect(url_for('index'))
    return render_template('signup.html', title=title, form=form)
Exemple #32
0
def register():
    title = "Phonebook | REGISTER"
    form = UserInfoForm()
    if request.method == "POST" and form.validate():
        username= form.username.data
        password= form.password.data
        email = form.email.data
        phone= form.phone.data

        new_user=User(username, email, phone, password)
        db.session.add(new_user)
        db.session.commit()

        welcome = Message(f'Welcome, {username}', [email])
        welcome.html = '<p>Thank you for signing up! Your phone is now in our phonebook</p>'
        mail.send(welcome)
        flash ("You have added your entry", "success")
        return redirect(url_for("index"))
    return render_template('registerphone.html', title= title, form=form)
Exemple #33
0
def recuperar():
    forms = Recuperar()
    if forms.validate_on_submit():
        print(forms.email.data)
        email = User.query.filter_by(email=forms.email.data).first()
        if email is not None:
            email.senha = "123@mudar"
            db.session.commit()
            print("EMAIL VINDO DO BANCO {}".format(email))
            msg = Message('Ola isso é um teste',
                          sender='*****@*****.**',
                          recipients=[email.email])
            msg.body = "Sua senha foi resetada para 123@mudar para mudar clique no link http://127.0.0.1:58000/form/alterarSenha"
            mail.send(msg)
            flash('Email disparado com sucesso!!!', 'info')
            return redirect(url_for('form.index'))
        else:
            flash("Email não cadastrado na base de dados", "warning")
            return redirect(url_for('form.index'))
    return render_template("recuperar.html", form=forms)
Exemple #34
0
    def test_delete_message(self):
        client = app.test_client()
        new_message = Message(author='Kelley',
                              content='delete me',
                              user_id='2')
        db.session.add(new_message)
        db.session.commit()

        new_id = new_message.id
        result = client.delete('/users/' + str(new_message.user_id) +
                               'messages/' + str(new_message.id))
        self.assertNotIn(b'<p> delete me </p>', result.data)
Exemple #35
0
def email_alert(message):
    msg = Message("%s Notice Fitboard" % (message),
                  recipients=["*****@*****.**"])
    msg.body = "NOTICE %s \n " % (message)
    mail.send(msg)
    return