Skip to content

Commit 6dff768

Browse files
committed
Fix #663
1 parent a3a33fc commit 6dff768

4 files changed

Lines changed: 126 additions & 1 deletion

File tree

cairis/daemon/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@
2626
import httplib
2727
from flask import Flask
2828
from flask_mail import Mail
29+
#from flask_security import Security, SQLAlchemyUserDatastore, user_registered
2930
from flask_security import Security, SQLAlchemyUserDatastore
31+
#from cairis.bin.add_cairis_user import addAdditionalUserData
3032
from flask_cors import CORS
3133
from cairis.core.Borg import Borg
3234
from cairis.daemon.WebConfig import *
3335
from .cdb import db
3436
from .models import User, Role
3537

38+
#app = Flask(__name__)
39+
40+
#@user_registered.connect_via(app)
41+
#def enroll(sender, user, confirm_token,confirmation_token=None,form_data = {}):
42+
# addAdditionalUserData(user.email, user.password)
43+
44+
3645
def create_app():
3746
options = {
3847
'port' : 0,

cairis/daemon/dev/__init__.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
__author__ = 'Robin Quetin, Shamal Faily'
19+
20+
import logging
21+
import os
22+
import sys
23+
if (sys.version_info > (3,)):
24+
import http.client
25+
else:
26+
import httplib
27+
from flask import Flask
28+
from flask_mail import Mail
29+
from flask_security import Security, SQLAlchemyUserDatastore, user_registered
30+
from flask_security import Security, SQLAlchemyUserDatastore
31+
from cairis.bin.add_cairis_user import addAdditionalUserData
32+
from flask_cors import CORS
33+
from cairis.core.Borg import Borg
34+
from cairis.daemon.WebConfig import *
35+
from .cdb import db
36+
from .models import User, Role
37+
38+
app = Flask(__name__)
39+
40+
@user_registered.connect_via(app)
41+
def enroll(sender, user, confirm_token,confirmation_token=None,form_data = {}):
42+
addAdditionalUserData(user.email, user.password)
43+
44+
45+
def create_app():
46+
options = {
47+
'port' : 0,
48+
'unitTesting': False
49+
}
50+
WebConfig.config(options)
51+
52+
b = Borg()
53+
app.config['DEBUG'] = True
54+
app.config['SECRET_KEY'] = b.secretKey
55+
app.config['SECURITY_PASSWORD_SALT'] = 'None'
56+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
57+
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:' + b.rPasswd + '@' + b.dbHost + '/cairis_user'
58+
59+
if (b.mailServer != '' and b.mailPort != '' and b.mailUser != '' and b.mailPasswd != ''):
60+
app.config['SECURITY_REGISTERABLE'] = True
61+
app.config['SECURITY_RECOVERABLE'] = True
62+
app.config['MAIL_SERVER'] = b.mailServer
63+
app.config['MAIL_PORT'] = b.mailPort
64+
app.config['MAIL_USE_SSL'] = True
65+
app.config['MAIL_USERNAME'] = b.mailUser
66+
app.config['MAIL_PASSWORD'] = b.mailPasswd
67+
app.config['SECURITY_EMAIL_SENDER'] = b.mailUser
68+
69+
b.logger.setLevel(b.logLevel)
70+
b.logger.debug('Error handlers: {0}'.format(app.error_handler_spec))
71+
app.secret_key = os.urandom(24)
72+
logger = logging.getLogger('werkzeug')
73+
logger.setLevel(b.logLevel)
74+
enable_debug = b.logLevel = logging.DEBUG
75+
76+
mail = Mail(app)
77+
cors = CORS(app)
78+
with app.app_context():
79+
db.init_app(app)
80+
user_datastore = SQLAlchemyUserDatastore(db,User, Role)
81+
security = Security(app, user_datastore)
82+
83+
from .main import main as main_blueprint
84+
app.register_blueprint(main_blueprint)
85+
db.create_all()
86+
return app
87+
88+
def create_test_app():
89+
options = {
90+
'port' : 0,
91+
'unitTesting': True
92+
}
93+
WebConfig.config(options)
94+
95+
b = Borg()
96+
app = Flask(__name__)
97+
app.config['DEBUG'] = True
98+
app.config['SECRET_KEY'] = b.secretKey
99+
app.config['SECURITY_PASSWORD_SALT'] = 'None'
100+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
101+
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:' + b.rPasswd + '@' + b.dbHost + '/cairis_user'
102+
b.logger.setLevel(b.logLevel)
103+
b.logger.debug('Error handlers: {0}'.format(app.error_handler_spec))
104+
app.secret_key = os.urandom(24)
105+
logger = logging.getLogger('werkzeug')
106+
logger.setLevel(b.logLevel)
107+
enable_debug = b.logLevel = logging.DEBUG
108+
db.init_app(app)
109+
user_datastore = SQLAlchemyUserDatastore(db,User, Role)
110+
security = Security(app, user_datastore)
111+
from .main import main as main_blueprint
112+
app.register_blueprint(main_blueprint)
113+
with app.app_context():
114+
db.create_all()
115+
return app

cairis/daemon/templates/security/forgot_password.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% include "security/_messages.html" %}
1111
<form action="{{ url_for_security('forgot_password') }}" method="POST" name="forgot_password_form">
1212
<div class="d-flex d-flex-column justify-content-center align-items-center">
13-
<h1>{{ _('Reset CAIRIS password') }}</h1>
13+
<h1>{{ _fsdomain('Reset CAIRIS password') }}</h1>
1414
</div>
1515
<div class="d-flex d-flex-column justify-content-center align-items-center">
1616
{{ forgot_password_form.hidden_tag() }}

docker/register_user.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
2+
23
<link href="login.css" rel="stylesheet" />
34
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
45
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />

0 commit comments

Comments
 (0)