<script>
import {mapGetters, mapActions} from 'vuex'
export default {
name: 'login',
data() {
return {
form: {
email: null,
password: null,
}
}
},
// computed: mapGetters(['user/USER_AUTH']),
methods: {
...mapActions({
loginUser: 'user/LOGIN_USER'
}),
submit() {
this.loginUser(this.form)
.then(() => this.$router.push('/'))
.catch(err => console.log(err))
}
}
}
</script>
actions: {
async LOGIN_USER({ commit }, form) {
const response = await axios.post('api/v1/login', form)
const user = await response.data
commit('UPDATE_USER_AUTH', user)
},
mutations: {
UPDATE_USER_AUTH(state, user) {
localStorage.token = user.token
localStorage.email = user.email
localStorage.name = user.name
localStorage.role = user.role
state.token = user.token
state.email = user.email
state.name = user.name
state.role = user.role
}
class DieCutSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = DieCut
@api.route('/diecuts')
def index():
items = DieCut.query.all()
items_schema = DieCutSchema(many=True)
result = items_schema.dump(items)
return jsonify(result)
items = TypeMaterial.query.all()
items_schema = TypeMaterialSchema(many=True)
results = items_schema.dump(items)
print(results)
return jsonify(results)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args,
# compare_type=True
compare_type=my_compare_type
def my_compare_type(context, inspected_column,
metadata_column, inspected_type, metadata_type):
# return False if the metadata_type is the same as the inspected_type
# or None to allow the default implementation to compare these
# types. a return value of True means the two types do not
# match and should result in a type change operation.
return None
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args,
compare_type=my_compare_type
)